Skip to content

Misleading promise rejection when adding document with _rev #144

Open
@sdvg

Description

@sdvg

When you try to call hoodie.store.add or hoodie.store.updateOrAdd an a fresh database with a document that contains id and _rev properties, the promise gets rejected with:

Error: Object with id "E06D0AC8-808F-D510-B689-410CFC7A56F0" already exists

While it's okay that the promise gets rejected, the message is misleading and should tell you about the disallowed _rev property.

Code to reproduce:

const remove = () => {
    return hoodie.store.removeAll();
};
const add = () => {
    return hoodie.store.updateOrAdd({"_rev":"2-14a948bba06970abd1a0acea5252c236","id":"E06D0AC8-808F-D510-B689-410CFC7A56F0"});
};
hoodie.ready.then(() => {
    remove()
    .then(add);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions