Search code examples
node.jsormnode-orm2

How do I use find operators on node-orm2 fields?


Node-ORM2 documentation states this:

1.2.1 Operators

To use more than a straightforward = or in operator you use a slightly different syntax like so:

model.find({
    field : { "operator" : "value" }
});

Those operators are:

Operator Values to use operator
Equals =
Less Than <, “less than”
Less Than or Equal to <=, “less than or equal to”
More than >, “more than”
More than or equal to >=, “more than or equal to”

Trying to filter a find where a fields is greater than like so:

Person.find({id: {">": 1000}}, function(err, res) {
});

The resulting query looks like this...

... WHERE `id` = `>` = `1000` ...

I also tried using the text operators "less than", it gives the same result. How can I do a WHERE id > 1000 query with node-orm2?


Solution

  • I was looking at the wrong documentation, if anyone is looking for the same answer, look at: https://github.com/dresende/node-orm2#conditions