Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create type of geoJSON in graphql. #4

Open
alex-knyazev opened this issue Jul 11, 2018 · 0 comments
Open

create type of geoJSON in graphql. #4

alex-knyazev opened this issue Jul 11, 2018 · 0 comments

Comments

@alex-knyazev
Copy link

Фильтры в packages/oda-apigraphql уже реализуют операции с геоданными (near, center и т.д):

near(value, idMap, id) {

однако чтобы это работало при создании mongoose-schema мы для сущности мы должны создавать индекс "2dsphere" для поля, содержащего geoJSON:
https://medium.com/@galford151/mongoose-geospatial-queries-with-near-59800b79c0f6

Мое предложение - расширить graphql-types, добавив туда geoJSON. При создании mongoose shcema сущности, если у поля установлен этот тип - создавать для него индекс, как в вышеприведенной статье:

var GasStationSchema = new Schema(
 {
  name: String,
  location: {
   type: { type: String },
   coordinates: []
  },
);
GasStationSchema.index({ location: "2dsphere" });
var GasStation = mongoose.model("GasStation", MessageSchema);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant