-
|
I have been using Single Table Design for quite a while using the Document Client. I generally append Is there a way I could do this more simply in ElectroDB with attribute Getters and Setters? Would I have to do this on each Entity within the single table or could it be done in some sort of context across all entities? Rather like #471 for the security context. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
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 }; |
Beta Was this translation helpful? Give feedback.
You need to add the timestamps to all your entities. Here's how I do it: