WatermelonDB icon indicating copy to clipboard operation
WatermelonDB copied to clipboard

How to disable create/update tracking

Open mfbx9da4 opened this issue 2 years ago • 3 comments

I have created_at and updated_at but I want to keep them as server values. How can I disable this automatic tracking that watermelon does?

mfbx9da4 avatar Aug 01 '22 11:08 mfbx9da4

I have the same issue, any answer on this?

wfl-junior avatar Sep 03 '22 18:09 wfl-junior

I found a workaround, I don't know if it is practical or if it has any side effects.

export class User extends Model {
  ...

  @field("_created_at")
  created_at: string;

  @field("_updated_at")
  updated_at: string;
}

export const userSchema = tableSchema({
  name: "users",
  columns: [
    ...
    {
      name: "_created_at",
      type: "string",
    },
    {
      name: "_updated_at",
      type: "string",
    },
  ],
});

wfl-junior avatar Sep 03 '22 19:09 wfl-junior

Yeah I just called mine server_created_at and server_updated_at

mfbx9da4 avatar Sep 03 '22 19:09 mfbx9da4

yup as long as it is not called "created_at" or "updated_at" it will not automatically track. Please close the issue if it is already fixed for you, thanks!

KrisLau avatar Sep 27 '22 13:09 KrisLau