0

When trying collection with test.collection.col name returns empty array:

db.collection('collection.col', {w: 1, strict: true}, function (err, collection) {
    if (err) { 
       console.log(err); // Collection collection.col does not exist. Currently in strict mode.
    }
});

But with {strict: false} the collection.col collection gets successfully.

P.S: I'm just noticed that this happens when collection name has name like path.path and doesn't happens in case path. So the following code works well:

db.collection('collection', {w: 1, strict: true}, function (err, collection) {
    if (err) { 
       console.log(err); // null
    }
});
Erik
  • 14,060
  • 49
  • 132
  • 218
  • 'official' json doesnt support dot notation !? – Gabe Rainbow Dec 22 '14 at 03:31
  • mongodb supports collection with dots like `system.indexes`, `system.js` and etc – Erik Dec 22 '14 at 04:29
  • `strict : true` means the call to `db.collection()` will return an error if the collection does not exist. That's the error your seeing. It's not related to the `.`'s in the field name. `.` characters are allowed in collection names, but not database names. – wdberkeley Dec 22 '14 at 05:57
  • @wdberkeley I'm 100% ensure that my 'collection.col' collection exists. And I think the problem in the following line https://github.com/mongodb/node-mongodb-native/blob/2.0/lib/db.js#L459 – Erik Dec 22 '14 at 06:59

0 Answers0