var LINK = mongoose.model('link', {
id: mongoose.Schema.Types.ObjectId,
linkA: Boolean,
linkB: Boolean,
}, 'link')
(model for LINK - here as reference)
When using mongoose on nodeJS I can use the find() function to return all documents in a collection:
var Test = LINK.find({}, (err, user) => {
if (err) console.log("error: " + err)
else console.log("users: " + user)
}, 4000)
which returns all the data in terminal. Easy, right?
But the problems arise when I try to use a query:
var Test = LINK.find({linkA:'true'}, (err, user) => {
if (err) console.log("error: " + err)
else console.log("users: " + user)
}, 4000)
The query at first didn't return any results (even though there were documents on mongodb populated beforehand). But after adding documents to mongodb via mongoose- the documents added can be accessed, but not any of the others that were created on the mongodb console.
Is there a reason for this? I'm suspicious that I'm using the find() function wrong but it seems to work fine when the documents were added via mongoose or I use an empty query so I'm not sure.
Any help would be appreciated. Thanks.