Skip to content

Commit 629447e

Browse files
authored
add metarecords to new Projects (#254)
1 parent a5ce55d commit 629447e

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

classes/Project/Project.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ export default class Project {
2525
if (!validation.isValid) {
2626
throw { status: 400, message: validation.errors }
2727
}
28-
28+
29+
payload._createdAt ??= Date.now().toString().slice(-6)
30+
payload._modifiedAt ??= -1
31+
payload._lastModified ??= payload.layers?.[0]?.pages?.[0]?.id ?? true
2932
console.log("Creating project...", payload.layers)
3033
try {
3134
return database.save(payload, "projects")

classes/Project/ProjectFactory.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,18 @@ export default class ProjectFactory {
104104
const metadata = manifest.metadata ?? []
105105
const layer = Layer.build( database.reserveId(), `First Layer - ${label}`, manifest.items )
106106

107+
const firstPage = layer.pages[0]?.id ?? true
108+
107109
// required properties: id, label, metadata, manifest, layers
108110
return {
109111
label,
110112
metadata,
111113
manifest: [ manifest.id ],
112114
layers: [ layer.asProjectLayer() ],
113-
tools: this.tools
115+
tools: this.tools,
116+
_createdAt: now,
117+
_modifiedAt: -1,
118+
_lastModified: firstPage,
114119
}
115120
}
116121

0 commit comments

Comments
 (0)