Closed faisal-rehman19 closed 8 months ago
your payload contain the created_at and updated_at field?
if yes, then remove it from the payload because watermelondb handle it internally.
your payload contain the created_at and updated_at field?
if yes, then remove it from the payload because watermelondb handle it internally.
no, I am not sending created_at
and updated_at
in payload.
I have defined these fields to be readonly
in my schema. So, watermelon won't let me send them while creating the record and will throw an error even if i try to.
just a random guess - did you add migration?
just a random guess - did you add migration?
No, I haven't added migrations, because the app is not in production yet. So whenever I make a change in schema, I just bump up the version number. The previously added data is lost, but it doesn't matter to me at the moment. So I think the absence of migrations is not the issue.
Oh,
export default class Damper extends Model {
static table = 'dampers';
@readonly @date('created_at') created_at; // <--------- Changes
@readonly @date('updated_at') updated_at; // <--------- Changes
@field('damper_inspection_id') damper_inspection_id;
should be probably
export default class Damper extends Model {
static table = 'dampers';
@readonly @date('created_at') createdAt; // <--------- Changes (camel case)
@readonly @date('updated_at') updatedAt; // <--------- Changes (camel case)
@field('damper_inspection_id') damper_inspection_id;
Oh,
export default class Damper extends Model { static table = 'dampers'; @readonly @date('created_at') created_at; // <--------- Changes @readonly @date('updated_at') updated_at; // <--------- Changes @field('damper_inspection_id') damper_inspection_id;
should be probably
export default class Damper extends Model { static table = 'dampers'; @readonly @date('created_at') createdAt; // <--------- Changes (camel case) @readonly @date('updated_at') updatedAt; // <--------- Changes (camel case) @field('damper_inspection_id') damper_inspection_id;
@primus11 thanks a lot. createdAt
and updatedAt
should be in camel case. I thought this naming convention is upto us and we name it based on how we want to access these properties in our javascript code.
I have added Automatic create/update tracking as per the documentation but it is not working for me. It just shows
0
for bothcreated_at
andupdated_at
. Here is myschema
code:Here is how my damper
model
class looks like:Here is how I am creating a
damper
record:When I see the Db file by opening it in
db browser for sqlite
, this is what I see(I seecreated_at: {}
on react nativeexperimental-debugger
):I am using the following versions
I am using this library for the first time. Let me know if I am making any mistake. I would appreciate any help in this regard. Thanks