You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Note: function passed to `database.write()` MUST be asynchronousconstnewPost=awaitdatabase.write(async=>{constpost=awaitdatabase.get('posts').create(post=>{post.title='New post'post.body='Lorem ipsum...'})constcomment=awaitdatabase.get('comments').create(comment=>{comment.post.set(post)comment.author.id=someUserIdcomment.body='Great post!'})// Note: Value returned from the wrapped function will be returned to `database.write` callerreturnpost})
class Posts extends Model {
static table = 'posts'
}
const insert = async () => {
try {
const users: Collection = RxDatabase.getCollections('posts');
// const postsModal = await users.modelClass.addComment({
// title: "New post222222",
// body: "Lorem ipsum...",
// subtitle: "Lorem ipsum...",
// isPinned: true,
// });
await users.modelClass.addComment({
title: "New post222222",
body: "Lorem ipsum...",
subtitle: "Lorem ipsum...",
isPinned: true,
})
console.log("🚀 ~ insert ~ postsModal:",)
} catch (error) {
console.log("🚀 ~ insert ~ error:", error)
}
}
The text was updated successfully, but these errors were encountered: