Giter VIP home page Giter VIP logo

Comments (5)

markstos avatar markstos commented on June 16, 2024 2

The recommended practice is define your index separately, using the index method. See:

http://mongoosejs.com/docs/api.html#schema_Schema-index

If this seems helpful to document in the README, a doc-patch is welcome.

Closing.

from mongoose-geojson-schema.

markstos avatar markstos commented on June 16, 2024

Sounds reasonable. Do you have a proposed patch?

from mongoose-geojson-schema.

lorlab avatar lorlab commented on June 16, 2024

Hi. I'll write here instead of opening a new issue because my problem has to do with a 2dshpere index.

I am trying to add an index to my schema:

var userSchema = mongoose.Schema({
    email: { type: String, unique: true },
    loc: { type: GeoJSON.Point, index: '2dsphere' }
});

but I get this error:

TypeError: Undefined type at `loc.index`
Did you try nesting Schemas? You can only nest using refs or arrays.

I apologize if this is my fault, as I am new to mongoose, however I tried using a simple Number array (which is the old way of storing coordinates, and I see lots of examples of this around) instead of GeoJSON.Point and it worked. Any suggestions? Thanks!

from mongoose-geojson-schema.

voronianski avatar voronianski commented on June 16, 2024

@lpirola @markstos do you have some recipe how to add 2dsphere index, currently I'm trying:

new Schema({
    district: {
        type: String,
        trim: true,
        unique: true,
        required: true
    },
    area: {
        type: GeoJSON.FeatureCollection,
        index: '2dsphere'
    }
});

but getting such error:

/Users/dmitri/api/node_modules/mongoose/lib/schema.js:479
    throw new TypeError('Undefined type `' + name + '` at `' + path +
          ^
TypeError: Undefined type `2dsphere` at `area.index`
  Did you try nesting Schemas? You can only nest using refs or arrays.

from mongoose-geojson-schema.

lpirola avatar lpirola commented on June 16, 2024

@voronianski i don't use 2dsphere. Here my example on working with geojson schema. https://github.com/nucleo-digital/gestaourbana-mapas/blob/master/app/layers/LayerModel.js

from mongoose-geojson-schema.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.