Coder Social home page Coder Social logo

Comments (5)

mbrimmer83 avatar mbrimmer83 commented on June 5, 2024 1

Did you manage to solve this?

Didn't go into detail but there is explicit check for updatedAt. I don't think these fields are mandatory but if defined they should be defined both in model and in schema.

Yes, I added updated_at and created_at to my schema's and that solved the issue for me. But that is interesting, I assumed that it would be checking for updated_at and not updatedAt. I break from naming conventions in my database and use camelcase instead of snake case, which is why I used updatedAt

from watermelondb.

mbrimmer83 avatar mbrimmer83 commented on June 5, 2024 1

Overall I don't like that Watermelon uses naming conventions like this. In my opinion you should be able to configure the columns you want to attach advanced field behaviors to. To my knowledge Sqlite doesn't care if you use snake-case or camelcase naming

from watermelondb.

mbrimmer83 avatar mbrimmer83 commented on June 5, 2024

The only thing I've read that would cause a pushed object not to marked as synced is if it changed during the sync and that hasn't happened in this case. All records are never marked as synced. Very Frustrating

from watermelondb.

mbrimmer83 avatar mbrimmer83 commented on June 5, 2024

Ok, so I wrapped my entire sync function in a try catch and get an error inside watermelon
TypeError: Cannot read property 'type' of undefined
Top of stack inside _setRaw.

at _setRaw (http://10.0.0.14:8081/../../node_modules/@nozbe/watermelondb/RawRecord/index.bundle//&platform=ios&hot=false&lazy=true&transform.engine=hermes&transform.routerRoot=app&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:20:28)
    at setRawSanitized (http://10.0.0.14:8081/../../node_modules/@nozbe/watermelondb/RawRecord/index.bundle//&platform=ios&hot=false&lazy=true&transform.engine=hermes&transform.routerRoot=app&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:95:12)

When I debug further I found that the error was here

function _setRaw(raw, key, value, columnSchema) {
  console.log(raw, key, value, columnSchema)
  var {
    type: type,
    isOptional: isOptional
  } = columnSchema;
  ...

The result of that console.log is

[object] updated_at 1708213289147 undefined

What is interesting is I don't use updated_at in my schema. I elected to go with all camel cased fields in my schema and not use the updated_at or created_at fields as the docs said they weren't required. So why does this function get called with updated_at even though the columSchema is undefined?
I think this may be a bug in Watermelon.

However, I do have updatedAt, createdAt, and deletedAt fields in my database, so maybe I should just map those fields and take advantage of watermelon db's built in advanced fields handling.

from watermelondb.

primus11 avatar primus11 commented on June 5, 2024

Did you manage to solve this?

Didn't go into detail but there is explicit check for updatedAt. I don't think these fields are mandatory but if defined they should be defined both in model and in schema.

from watermelondb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.