Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

"Can't use add op without position" adding properties to object #12

@withoutlogin

Description

@withoutlogin

Hi,

I think there's some kind of regression about following closed issue:
#6

With the latest npm version (1.0.0), I have following issue:

import * as jsonpatch from "fast-json-patch";
import toMongodb from "jsonpatch-to-mongodb";

const obj1 = { key: "value" };
const obj2 = { key: "value", newKey: "newValue" };
const patch = jsonpatch.compare(obj1, obj2); // [ { op: 'add', path: '/newKey', value: 'newValue' } ] 
toMongodb(patch); // throws: Unsupported Operation! can't use add op without position

As you can see patch is fully correct and should result with {$set: {newKey: "newValue"}}.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions