MongoDB.live, free & fully virtual. June 9th - 10th. Register Now MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

Can't extract geo keys - Working with Atlas but not Local MongoDB

My Model’s geo data implementation portion below

startLocation: {
      // GeoJSON
      type: {
        type: String,
        default: 'Point',
        enum: ['Point']
      },
      coordinates: [Number],
      address: String,
      description: String
    },
    locations: [
      {
        type: {
          type: String,
          default: 'Point',
          enum: ['Point']
        },
        coordinates: [Number],
        address: String,
        description: String,
        day: Number
      }
    ]

Same Request Body for each case below

{
    "name": "The Test Tourxx",
    "duration": 1,
    "maxGroupSize": 1,
    "difficulty": "medium",
    "price": 501,
    "summary": "Nothing exciting here man!",
    "imageCover": "tour-3-cover.jpg",
    "ratingsAverage": 4,
    "guides": ["5e85e24bd1b3f918dc07bb3d", "5e85e262d1b3f918dc07bb3e"]
}

Response when connected local MongoDB below

{
    "status": "error",
    "error": {
        "driver": true,
        "name": "MongoError",
        "index": 0,
        "code": 16755,
        "errmsg": "Can't extract geo keys: { _id: ObjectId('5e85fc64a4031f1734b55515'), startLocation: { type: \"Point\", coordinates: [] }, ratingsAverage: 4, ratingsQuantity: 0, rating: 4.5, images: [], createdAt: new Date(1585839200315), startDates: [], secretTour: false, guides: [ ObjectId('5e85e24bd1b3f918dc07bb3d'), ObjectId('5e85e262d1b3f918dc07bb3e') ], name: \"The Test Tourxx\", duration: 1, maxGroupSize: 1, difficulty: \"medium\", price: 501, summary: \"Nothing exciting here man!\", imageCover: \"tour-3-cover.jpg\", locations: [], slug: \"the-test-tourxx\", __v: 0 }  Point must only contain numeric elements",
        "statusCode": 500,
        "status": "error"
    },
    "stack": "MongoError: Can't extract geo keys: { _id: ObjectId('5e85fc64a4031f1734b55515'), startLocation: { type: \"Point\", coordinates: [] }, ratingsAverage: 4, ratingsQuantity: 0, rating: 4.5, images: [], createdAt: new Date(1585839200315), startDates: [], secretTour: false, guides: [ ObjectId('5e85e24bd1b3f918dc07bb3d'), ObjectId('5e85e262d1b3f918dc07bb3e') ], name: \"The Test Tourxx\", duration: 1, maxGroupSize: 1, difficulty: \"medium\", price: 501, summary: \"Nothing exciting here man!\", imageCover: \"tour-3-cover.jpg\", locations: [], slug: \"the-test-tourxx\", __v: 0 }  Point must only contain numeric elements\n    at Function.create (C:\\Users\\Cody\\Desktop\\X-Files\\NodeJS\\4-natours\\node_modules\\mongodb\\lib\\core\\error.js:43:12)\n    at toError (C:\\Users\\Cody\\Desktop\\X-Files\\NodeJS\\4-natours\\node_modules\\mongodb\\lib\\utils.js:149:22)\n    at C:\\Users\\Cody\\Desktop\\X-Files\\NodeJS\\4-natours\\node_modules\\mongodb\\lib\\operations\\common_functions.js:265:39\n    at handler (C:\\Users\\Cody\\Desktop\\X-Files\\NodeJS\\4-natours\\node_modules\\mongodb\\lib\\core\\sdam\\topology.js:913:24)\n    at C:\\Users\\Cody\\Desktop\\X-Files\\NodeJS\\4-natours\\node_modules\\mongodb\\lib\\cmap\\connection_pool.js:352:13\n    at handleOperationResult (C:\\Users\\Cody\\Desktop\\X-Files\\NodeJS\\4-natours\\node_modules\\mongodb\\lib\\core\\sdam\\server.js:487:5)\n    at MessageStream.messageHandler (C:\\Users\\Cody\\Desktop\\X-Files\\NodeJS\\4-natours\\node_modules\\mongodb\\lib\\cmap\\connection.js:270:5)\n    at MessageStream.emit (events.js:311:20)\n    at processIncomingData (C:\\Users\\Cody\\Desktop\\X-Files\\NodeJS\\4-natours\\node_modules\\mongodb\\lib\\cmap\\message_stream.js:144:12)\n    at MessageStream._write (C:\\Users\\Cody\\Desktop\\X-Files\\NodeJS\\4-natours\\node_modules\\mongodb\\lib\\cmap\\message_stream.js:42:5)\n    at doWrite (_stream_writable.js:441:12)\n    at writeOrBuffer (_stream_writable.js:425:5)\n    at MessageStream.Writable.write (_stream_writable.js:316:11)\n    at Socket.ondata (_stream_readable.js:714:22)\n    at Socket.emit (events.js:311:20)\n    at addChunk (_stream_readable.js:294:12)"
}

Response when connected to MongoDB Atlas(Removed unrelated potion) below

{
    "status": "success",
    "data": {
        "tour": {
            "startLocation": {
                "type": "Point",
                "coordinates": []
            },
            "ratingsAverage": 4,
            "images": [],
            "guides": [
                "5e85e24bd1b3f918dc07bb3d",
                "5e85e262d1b3f918dc07bb3e"
            ],
            "_id": "5e85fb952754013728fc950c",
            "name": "The Test Tourxx",
            "duration": 1,
            "maxGroupSize": 1,
            "difficulty": "medium",
            "price": 501,
            "summary": "Nothing exciting here man!",
            "imageCover": "tour-3-cover.jpg",
            "locations": [],
            "__v": 0,
        }
    }
}

As it can be seen local db throws error when creating empty array for “locations” but Atlas does it just fine.Please Help me identify the cause.

Mongoose: 5.9.7
Mockgoose: Not Used in the project
MongoDB: 4.2.3(Local and Atlas both)

Welcome to the community @Kebby_Otis!

Are you also using Mockgoose and experiencing the reported issue, or do you mean you have a similar error message in your application? If you are using Mockgoose, the issue you referenced suggests upgrading to Mockgoose 7.x or later.

The Mockgoose README also notes the package as deprecated and recommends using mongodb-memory-server instead.

So others can help investigate the issue, can you:

  • clarify whether you are using Mockgoose (and if so, what version)
  • share a snippet of code that returns this error message for you

Regards,
Stennie