Skip to content
Discussion options

You must be logged in to vote

You need to add the timestamps to all your entities. Here's how I do it:

import {
  Attribute,
} from 'electrodb';

export const TIMESTAMP_ATTRIBUTES = {
  createdAt: {
    type: 'string',
    readOnly: true,
    // required: true,
    default: () => DateTime.now().iso(),
    set: (value, schema) => {
      return DateTime.now().iso();
    },
  },
  updatedAt: {
    type: 'string',
    readOnly: true,
    watch: '*',
    set: (value, schema) => {
      return DateTime.now().iso();
    },
  },
} as const satisfies { [attribute: string]: Attribute };

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@owain68
Comment options

@zirkelc
Comment options

Answer selected by owain68
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants