As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
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');
var doc = {};
doc.a = false;
doc.b = 0;
falseTest.save(doc, function(err, result) {
if (err) {
response.error(err);
} else {
falseTest.find({}, function(err, result) {
if (err) {
return response.error(err);
}
response.body = result;
response.complete();
});
}
});
}
```
D
Davide Neri
said
over 9 years ago
ups I'm very sorry, my bad.
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
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?