I created a database (scriptDB) and have stored information (more than 40 properties of about 600 people-students-).
var obj = {
alumne_id: email,
alumne_ordre: nomsencer_ordre,
alumne_timestamp: {created: new Date (). getTime (), changed:'', editor: 'unedited'},
alumne_nom: {nom: nomREAD, cognom1: cognom1READ, cognom2: cognom2READ, cognoms: cognomsREAD, nomsencer: nomsencerREAD},
(...)
}
I stored this object in my database:
var stored = db.save(ob);
I defined thus, properties of objects and have my stored. This works perfectly and update data, for example, change “alumne_nom.nom” to a new value: ‘Joana’
Now I want to add new properties to all or some of these objects (students).
The problem is that I can add a property as
newproperty1
with:
stored.newproperty1 = '50 '
But I can not do:
stored.newproperty1.sub1
stored.newproperty1.sub2
stored.newproperty1.sub3
Does anyone know how I can add these subproperties?
To add “subproperties” you need to first define the property. You can do it by setting an empty object to it, e.g.
You could already pass the subs definitions on the braces as you do with the object as well: