【发布时间】:2018-09-26 02:55:43
【问题描述】:
假设我有以下代码:
let ref1 = db.collection('user').doc('u1')
let ref2 = db.collection('user').doc('u2')
let batch = this.db.batch()
let obj = {foo:'bar'}
batch.set(ref1, obj);
obj.foo = 'not bar anymore'
batch.set(ref2, obj);
batch.commit();
firestore 会制作 obj 的深层副本还是浅层副本?换句话说,一旦查询运行并且我检查了我的数据库,文档'u1' 的值会变成{foo:'bar'} 还是{foo:'not bar anymore bar'}?
【问题讨论】:
标签: javascript node.js firebase google-cloud-firestore deep-copy