question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'set' of undefined

See original GitHub issue

Hi,

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:closed
  • Created 4 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
azizhkcommented, Feb 25, 2020

It’s not the recommended way to do it. You lose a lot of safeguard checks related to ensuring wrap in action & create/update.

0reactions
stale[bot]commented, Aug 24, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot Read Property of Undefined in JavaScript - Rollbar
The TypeError : Cannot read property of undefined is one of the most common type errors in JavaScript. It occurs when a property...
Read more >
Cannot read property 'set' of undefined in javascript
I solved it by calling toObject() method of the fabric. Earlier I was using fabric 1.x and was going through a project revamp....
Read more >
Uncaught TypeError: Cannot read property of undefined In
Uncaught TypeError : Cannot read property of undefined error occurs in Chrome when you read a property or call a method on an...
Read more >
Cannot read property of undefined in JavaScript - Stack Diary
The Cannot read property '<property>' of undefined error is thrown when you try to access a property of an undefined value.
Read more >
TypeError: Cannot read property 'set' of undefined #768 - GitHub
internal/modules/cjs/loader.js:1122 throw err; ^ TypeError: Cannot read property 'set' of undefined [90m at Object.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found