0

I executed:

mongoimport -d chessCyberWar -c DataNode test.json

and ended up with this statement:

connected to: localhost
imported 1 document

When I check the collection, it is still empty though.

My collection DataNode has this scheme:

Name: { type: String, required: true, unique: true },
        Lat: Number,
        Lng: Number,
        X: Number,
        Y: Number,
        Type: Number,
        PvP: { type: Boolean, default: false },
        Owners: [{ type: mongoose.Schema.Types.ObjectId, ref: "Player" }]

And the test.json file has this content:

{
  "Name": "Dew Drop Inn",
  "Lat": 51.5264588,
  "Lng": -0.8146601,
  "X": 65239,
  "Y": 43573,
  "Type": 28,
  "PvP": false,
  "Owners": [ ]
}

How come it says the document has been imported, but when I search for it, there is nothing there?

P.S. for searching I used this:

db.DataNode.find({ Type: { $ne: -1 }}...
Michal Krča
  • 149
  • 3
  • 15
  • 1
    `use chessCyberWar`. The default namespace is `test`, so you need to switch it. For your mongoose model, you similarly need to connect to the correct database and note that mongoose models "pluralize" and "lowercase" collection names by default. So you probably want to specify that collection name as the "third argument". i.e `mongoose.model('DataNode', dataNodeSchema, "DataNode")`. Otherwise it's looking for `"datanodes"` as the collection name instead. – Neil Lunn Aug 28 '17 at 13:26
  • Thank you so much. The third argument solved it all. :) – Michal Krča Aug 28 '17 at 13:35

0 Answers0