|
@@ -11,41 +11,41 @@ const delay = ms => new Promise(r => setTimeout(r.bind(ms), ms))
|
|
|
|
|
|
//while(true){
|
|
|
//await (new Savable({timestamp: (new Date).getTime(), r: Math.random()})).save()
|
|
|
- //let person = new Savable({
|
|
|
- //name: 'Mykola',
|
|
|
- //surname: 'Silniy',
|
|
|
- //phones: ['105', '1'],
|
|
|
- //children: [
|
|
|
- //new Savable({
|
|
|
- //name: 'Marina',
|
|
|
- //surname: 'Silnaya',
|
|
|
- //phones: ['105', '1000503']
|
|
|
- //}),
|
|
|
- //new Savable({
|
|
|
- //name: 'Andrey',
|
|
|
- //surname: 'Silniy',
|
|
|
- //phones: ['103', '1000502']
|
|
|
- //}),
|
|
|
- //new Savable({
|
|
|
- //name: 'Fedor',
|
|
|
- //surname: 'Ivanova',
|
|
|
- //phones: ['102', '1000504'],
|
|
|
- //notebook: new Savable({
|
|
|
- //brand: 'dubovo'
|
|
|
- //})
|
|
|
- //})
|
|
|
- //]
|
|
|
- //})
|
|
|
+ let person = new Savable({
|
|
|
+ name: 'Mykola',
|
|
|
+ surname: 'Silniy',
|
|
|
+ phones: ['105', '1'],
|
|
|
+ children: [
|
|
|
+ new Savable({
|
|
|
+ name: 'Marina',
|
|
|
+ surname: 'Silnaya',
|
|
|
+ phones: ['105', '1000503']
|
|
|
+ }),
|
|
|
+ new Savable({
|
|
|
+ name: 'Andrey',
|
|
|
+ surname: 'Silniy',
|
|
|
+ phones: ['103', '1000502']
|
|
|
+ }),
|
|
|
+ new Savable({
|
|
|
+ name: 'Fedor',
|
|
|
+ surname: 'Ivanova',
|
|
|
+ phones: ['102', '1000504'],
|
|
|
+ notebook: new Savable({
|
|
|
+ brand: 'dubovo'
|
|
|
+ })
|
|
|
+ })
|
|
|
+ ]
|
|
|
+ })
|
|
|
|
|
|
- //await person.save()
|
|
|
- //console.log(person)
|
|
|
+ await person.save()
|
|
|
+ console.log(person)
|
|
|
|
|
|
- //await delay(3000)
|
|
|
+ await delay(3000)
|
|
|
//}
|
|
|
|
|
|
- let person = new Savable()
|
|
|
- person._id = ObjectID('5c7bd603ce3cbc409978203e');
|
|
|
- console.log(person)
|
|
|
+ //let person = new Savable()
|
|
|
+ //person._id = ObjectID('5c7bd603ce3cbc409978203e');
|
|
|
+ //console.log(person)
|
|
|
|
|
|
let child = new Savable({
|
|
|
name: 'New One Child',
|
|
@@ -53,12 +53,9 @@ const delay = ms => new Promise(r => setTimeout(r.bind(ms), ms))
|
|
|
phones: ['105', '1000506']
|
|
|
});
|
|
|
|
|
|
- console.log(await person)
|
|
|
- console.log(await person.children[10])
|
|
|
- console.log(await person.children[10].father)
|
|
|
- console.log(await person.children[10].father.children[9])
|
|
|
+ //console.log(await person)
|
|
|
//console.log(await person.children[1])
|
|
|
- ;(await person).children.push(child)
|
|
|
+ person.children.push(child)
|
|
|
child.father = person
|
|
|
|
|
|
//console.log(person)
|
|
@@ -66,6 +63,16 @@ const delay = ms => new Promise(r => setTimeout(r.bind(ms), ms))
|
|
|
|
|
|
await person.save()
|
|
|
|
|
|
+
|
|
|
+ //console.log(await person.children[3])
|
|
|
+ let p2 =new Savable({_id: ObjectID('5c7bf8f04a3a3299f7deda0d' )}, true) //check for cache hit
|
|
|
+ ;(await new Savable({_id: ObjectID('5c7bf8f04a3a3299f7deda0d' )}, true)) //check for cache hit
|
|
|
+ ;(await p2)
|
|
|
+ console.log('parent 2', p2)
|
|
|
+ console.log(await p2.children[3]) //check for other hit
|
|
|
+ console.log(await person.children[3].father)
|
|
|
+ console.log(await person.children[3].father.children[1])
|
|
|
+
|
|
|
//let obj = {
|
|
|
//then(cb){
|
|
|
//process.nextTick(() => cb(obj))
|