Skip to content

Commit

Permalink
FIX: tables without primary sort key
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael O'Brien committed Nov 25, 2021
1 parent 911e7b3 commit 87ea18b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export class Schema {
let primary = indexes.primary
let fields = this.schemaModelFields = {
[primary.hash]: { type: 'string', required: true, value: `${SchemaKey}` },
[primary.sort]: { type: 'string', required: true, value: `${SchemaKey}:\${name}` },
format: { type: 'string', required: true },
indexes: { type: 'array', required: true },
name: { type: 'string', required: true },
Expand All @@ -120,6 +119,9 @@ export class Schema {
queries: { type: 'object', required: true },
version: { type: 'string', required: true },
}
if (primary.sort) {
fields[primary.sort] = { type: 'string', required: true, value: `${SchemaKey}:\${name}`}
}
this.models[SchemaModel] = new Model(table, SchemaModel, {fields})
}

Expand All @@ -128,12 +130,14 @@ export class Schema {
let primary = indexes.primary
let fields = this.migrationModelFields = {
[primary.hash]: { type: 'string', value: `${MigrationKey}` },
[primary.sort]: { type: 'string', value: `${MigrationKey}:\${version}` },
date: { type: 'date', required: true },
description: { type: 'string', required: true },
path: { type: 'string', required: true },
version: { type: 'string', required: true },
}
if (primary.sort) {
fields[primary.sort] = { type: 'string', value: `${MigrationKey}:\${version}` }
}
this.models[MigrationModel] = new Model(this.table, MigrationModel, {fields, indexes})
}

Expand Down

0 comments on commit 87ea18b

Please sign in to comment.