是否需要先创建文档,然后再调用pouchdb db.putAttachment 函数将数据附加到文档

Is it required create the document first, before calling pouchdb db.putAttachment function to attach data to the document

问题:

调用 pouchdb 'putAttachment' 函数不会将附件详细信息写入 db。

背景:

根据 pouchdb 站点提供的示例,我编写了创建附件的代码 (http://pouchdb.com/guides/attachments.html)。

db.putAttachment('mydoc', 'myattachment.png', myBase64String, 'image/png');

问题:

在我开始调用 db.putAttachment 函数创建附件之前是否需要先创建 'mydoc'?

如果 'mydoc' 文档还没有,那么 pouchdb 会自动创建它。

在我调用代码 'db.putAttachment' 的那一刻,什么也没有发生(没有 'mydoc' 文档被创建或数据库中没有创建附件)

不,如果文档不存在,PouchDB 会为您创建它。