代码之家  ›  专栏  ›  技术社区  ›  KhoPhi

按下以列出FireStore

  •  0
  • KhoPhi  · 技术社区  · 7 年前

    我的问题很简单:

    我可以吗 something like this 在当前的消防库中(如4.2.0)? 如果是,请怎么办?

    const itemsRef = db.list('items');
    itemsRef.push({ name: newName });
    

    我只想推到一个数组,似乎在网上找不到任何东西。

    1 回复  |  直到 7 年前
        1
  •  0
  •   Tim Martens    7 年前

    Sure you can !

    向集合中添加文档
    要使用生成的ID向集合添加新文档,请使用add()方法。此方法使用泛型类提供的类型来验证其类型结构。

    因此,在您的示例中,这将是:

    constructor(private db: AngularFirestore): {
        const itemsCollections = db.collection('items');
        itemsCollections.add({ name: 'NewName' });
    }