RavenDB NodeJs 补丁和增量 buggy

问题描述 投票:0回答:1

将 RavenDB

5.4.100
与 NodeJs typescript 客户端一起使用时,

我一直在尝试通过以下方式更新文档

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

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

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

但是我总是在指定的属性中得到一个空对象而不是数字数据:

"qty": {},

而不是

"qty": 123,

有人知道解决方法吗?我认为这是一个错误

我期望该属性具有数值

node.js patch ravendb
1个回答
0
投票

我们验证了您的案例,它似乎运行正常。

为了您的方便,我粘贴了片段。

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));
});`
© www.soinside.com 2019 - 2024. All rights reserved.