techfort / LokiJS

javascript embeddable / in-memory database
http:/techfort.github.io/LokiJS
MIT License
6.73k stars 482 forks source link

Can't save a document with an attribute named "ttl" #884

Closed mathcoll closed 2 years ago

mathcoll commented 3 years ago

Hello,

I can't get an attribute "ttl" to be saved on a document in a collection. I'm not talking about the ttl attribute of the collection. using lokijs v1.5.12

Here is a sample code for illustration :

var my_ttl = "1234";
var doc = {
    ttl: (my_ttl).toString(),
    another_ttl_string: (my_ttl).toString(),
    another_ttl_integer: parseInt(my_ttl, 10),
};
var db = new loki("my_db.json", {autoload: true, autosave: true});
var coll = db.getCollection("documents");
coll.insert(doc);

And the result in Loki Db file is :

"data":[{
    "$loki":1,
    "ttl":null, // Hum ... what wrong here ??
    "another_ttl_string":"1234", // So a string ; make sense
    "another_ttl_integer":1234, // So an integer ; perfect
}]

So as you can see, I'm just expecting the ttl to be save in Loki document, is there any constraint on naming this attribute ?

Thanks

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.