Best way to store geojson data using loopback rest api
New to loopback, but happy to configure my first node based on RestAPI. I can create models and have related tables created in the data warehouse. My models need properties which are geojson datatype, form string:
{"type": "Feature", "geometry": {"type": "Point", "coordinates": [125,6, 10,1]}}
Some points. Other polylines or polygons. My question is what is the best way to set geojson properties in the model schema. I could just set the datatype to a string I think, but I hope there is something more elegant. Ideally, I would like to set up a spot check that will check that the submitted data is valid geojson. Also I need to be able to query models by location, eg. return data within lat / lng.
I choose MYSQL as my data warehouse, but only because of past experience. If a different data source is preferred, I will change.
source to share
I see Raymond has answered this question on the mailing list as well.
- For NoSQL DB like mongodb, you can save the object directly as a nested document.
- For relational databases like MySQL, you can define the property type as Object. LoopBack will save them as TEXT / CLOB.
- If the DB has its own types for geodata-related data, we can potentially improve the type mapping for connectors to use them.
https://groups.google.com/forum/#!topic/loopbackjs/D0WCPIfHhR8
source to share