Cannot read property 'set' of undefined
See original GitHub issueHi,
I am fairly new to WatermelonDB. I have read the documentations, and trying to build a proof of concept as per the instructions and the sample provided.
However, I got stuck with the error below when using the exact same schema, models, and generate files provided with the sample.
Cannot read property ‘set’ of undefined when executing prepareCreate on the generate.js file, I am getting that error message. Code below
const makePost = (db, blog, i) =>
db.collections.get(‘posts’).prepareCreate(post => {
post.title = postNames[i] || post.id
post.subtitle = ID: ${post.id}
post.body = postBody
post.blog.set(blog) //Cannot read property 'set' of undefined
})
if I added post.blog = new Map()
before the offending line, it passes this step, however, querying the data after returns wrong result.
If I commented that offending line, the database batch update works with no problems. But, again querying the data does not return matching results to the sample data generated.
Just to confirm, I am using the same exact model files in the sample provided, and the following watermelonDB releases:
“@nozbe/watermelondb”: “0.16.0-9”
“@nozbe/with-observables”: “1.0.6-0”
Any help would be much appreciated
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (4 by maintainers)
Top GitHub Comments
It’s not the recommended way to do it. You lose a lot of safeguard checks related to ensuring wrap in action & create/update.
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.