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

更新数据库中文档的id

  •  3
  • karruma  · 技术社区  · 8 年前

    this.db.get('oldId')
      .then(document => {
        this.logsheetDB.put({
          _id: 'newId',
          _rev: document._rev,
          objectToInsert,
        });
      })
    

    错误:

    {"status":409,"name":"conflict","message":"Document update conflict"}"
    

    感谢您的帮助。

    1 回复  |  直到 8 年前
        1
  •  3
  •   Kurt Schwanda Alexis Côté    6 年前

    您不能更改文档 _id

    如果您获得一个文档并更改其 id ,您将使用不同的 身份证件 _rev .

    为什么需要删除 当更改 _id ? 我们通常通过 ,我们正在创建一个新文档,因此没有可修改的现有文档。