-
-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Labels
help wantedExtra attention is neededExtra attention is needed
Description
In the following example, the final post only has one (1) comment, whereas I would expect it to have two (2).
const postSchema = z.object({
get comments() {
return z.array(commentSchema)
},
})
const commentSchema = z.object({
text: z.string(),
})
const posts = new Collection({ schema: postSchema })
const comments = new Collection({ schema: commentSchema })
posts.defineRelations(({ many }) => ({
comments: many(comments),
}))
const post = await posts.create({
comments: [await comments.create({ text: 'First!' })]
});
const comment2 = await comments.create({ text: 'Second!' });
const updatedPost = await posts.update(post, {
data(p) {
p.comments = [ ...post.comments, comment2 ];
// p.comments.push(comment2) also doesn't work
}})
console.log(updatedPost.comments.length)I'm using Bun 1.3.2, msw 2.12.2, msw/data 1.1.2 and zod 4.1.12.
kettanaito
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is needed