Hey!
Thanks for this awesome library.
In the current version it seems it's not possible to update nested objects atomically.
Here is an example to illustrate what I mean.
Given the following schema:
interface User {
firstName: string;
metadata?: {
nestedKey1?: number;
nestedKey2?: boolean;
}
}
If I want to update specifically one property inside the metadata object without replacing the whole object, I can do it by creating an atomic update object like this:
const userId = db.users.id('my-id);
// This works, but does not compile
await db.users.update(userId, {
"metadata.nestedKey1": 123
});
It currently works fine, even using Typesaurus. However, the UpdateData type does not support it so it result in a compilation error.
I don't know if the best way would be to update the UpdateData type or to create a dedicated type but if you point me the right way to do it, I would be happy to submit a PR.
Hey!
Thanks for this awesome library.
In the current version it seems it's not possible to update nested objects atomically.
Here is an example to illustrate what I mean.
Given the following schema:
If I want to update specifically one property inside the metadata object without replacing the whole object, I can do it by creating an atomic update object like this:
It currently works fine, even using Typesaurus. However, the
UpdateDatatype does not support it so it result in a compilation error.I don't know if the best way would be to update the
UpdateDatatype or to create a dedicated type but if you point me the right way to do it, I would be happy to submit a PR.