By checking again now I just found out couple of weeks ago I added a line on my custom "save" method to avoid saving null and undefined elements on the database.
But I didn't realize that rather than using a if ( variable != null ) I just used a if ( variable ) ...that rejects null and undefined, but also false and 0 -- I actually didn't know js was considering 0 as false, still learning :D
thanks for your response
M
Michael
said
almost 7 years ago
How are you getting doc? The below code creates an entity and then retrieves it, and both false and 0 are saved and retrieved properly.
```
function onRequest(request, response, modules){
var falseTest = modules.collectionAccess.collection('falseTest');
Davide Neri
For example:
doc.zeroNum = 0;
doc.zeroText = "0";
doc.falseBool = false;
doc.falseText = "false";
access.collection("Test").save(doc, function (err, result) { ... });
Will only store "zeroText" and "falseText" but not the others.
I could store everything as text and turn it into int / bool when I read it from the database... but it's not best.
Is there a way to store them as int and bool even when they're 0 and false?