These are chat archives for LearnBoost/mongoose

Feb 2015
Ruben Costa
Feb 21 2015 12:48

Hi all, i run into something strange and i want to know if i'm doing it wrong with mongoose.

This works on mongo:
db.words.find({$and: [
{text:{$nin:['love']}}, {text:new RegExp('^l')}]},

But when i try to do it in node with mongoose like this:
var query = Word.find({text: new RegExp('^' + req.params.word)}, 'text alias');
if (req.params.sort == '-timesDefined') {
var nin = Array.isArray(req.query.nin) ? req.query.nin : [req.query.nin];
query.nin('text', nin);
sort = {timesDefined:-1};
with req.params.word = 'l' and req.query.nin = 'love' it gives back love in the result;

Samiran Raj Boro
Feb 21 2015 14:27
Hello my $and does not work as expected. It returns all the documents. Please let me know what did i do wrong
Kilian Ciuffolo
Feb 21 2015 20:49
Hello everyone! I just figured that mongoose doesn't accept subdocuments path but just the final field
if I do = where foo is a subdocument it doesn't work, same thing for Foos.create({ foo: { bar: 'bar' } })