nedb
nedb copied to clipboard
How add new colum if the colum dosn't exist ?
Hello i am developing application witch use the nedb (by the way it's great) now the issue is i have added some new fields to the database but the previous code don't have in the this fields in the database is there any way to add this filed in nedb and i can't clean slate the database since there can be 100 of files already there since user using the app right now
If a field doesn't exist, NEDB will create it automatically (e.g. db.update({'foo.bar': 'value'})
will create a field of "bar" inside "foo").
OK but now my issues is i need to check if the filed exist before reading is there any way since my code stop from there when it's didn't find the field. And thank you very much for quick response
Maybe there is a better way to handle this, but without updating your database, you can provide a default value like let x = db.find({key: value}) || value;
I run into the same problem a lot too so I'm also interested to know if anyone has a better solution.