RavenDB NodeJs patch and increment buggy

40 Views Asked by At

While using RavenDB 5.4.100 with NodeJs typescript client,

I've been trying to update a document via session.advanced.increment('product/1-A', 'qty', 123);

and session.advanced.patch('product/1-A', 'qty', 123);

https://github.com/ravendb/ravendb-nodejs-client#advanced-patching

But I always get an empty object in the specified property rather than the numeric data:

"qty": {},

instead of

"qty": 123,

does anyone know a workaround? I think it's a bug

I was expecting the property to have a numeric value

1

There are 1 best solutions below

0
Marcin On

We verifed your case and it seems to be working properly.

I'm pasting snippet for your convience.

class Product {
    id: string;
    qty: number;
}

describe("patch", function () {
    let store: IDocumentStore;

    it("test", async () => {
        const product = new Product();

        {
            // arrange
            const session = store.openSession();
            await session.store(product);
            await session.saveChanges();
        }
        {
            // act
            const session = store.openSession();
            session.advanced.patch(product.id, "qty", 123);
            await session.saveChanges();
        }
        {
            // assert
            const session = store.openSession();
            const loadedProduct = await session.load<Product>(product.id);
            assertThat(loadedProduct.qty)
                .isEqualTo(123);
        }
    });

    beforeEach(async function () {
        store = await testContext.getDocumentStore();
    });

    afterEach(async () =>
        await disposeTestDocumentStore(store));
});`