Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check a column for NULL values in node-orm

I'm using the orm package in node.js and I'm trying to query the database using find() on one of my models. However, I can't figure out how to check a column for NULL values using find(). Is there a way to do this?

like image 720
mdm Avatar asked Nov 08 '16 10:11

mdm


1 Answers

If the sent_at field is not there when its not set then:

db.emails.find({sent_at: {$exists: false}})

If its there and null, or not there at all:

db.emails.find({sent_at: null})

Reference: Query for nul fields

Note: Since you didn't mention the database name nor the orm which you used assuming the database as mongodb.

Hope this helps.

like image 132
SUNDARRAJAN K Avatar answered Nov 09 '22 07:11

SUNDARRAJAN K