-
-
Notifications
You must be signed in to change notification settings - Fork 688
Open
Description
Hello,
I have following database:
import Dexie, {Table} from "dexie";
import 'dexie-observable';
import dexieCloud from 'dexie-cloud-addon';
import {ulid} from "ulidx";
Dexie.Observable.createUUID = () => ulid();
export class DatabaseService extends Dexie {
exercises!: Table<Exercise>;
trainingPlans!: Table<TrainingPlan>;
trainingPlanExercises!: Table<TrainingPlanExercise>;
trainings!: Table<Training>;
exerciseExecutions!: Table<ExerciseExecution>;
profiles!: Table<Profile>;
constructor() {
super('MyDB', { addons: [dexieCloud] });
this.version(2).stores({
// Primary key and indexed props
exercises: '$$id',
trainingPlans: '$$id',
trainings: '$$id',
trainingPlanExercises: '[trainingPlanId+exerciseId]',
exerciseExecutions: '$$id,exerciseId,date',
profiles: 'id'
});
// ... more code follows ...
}and locally it works perfectly.
Problem started when I tried to use dexieCloud.
Then adding new records to database fails with following error:
DexieError2 {name: 'ConstraintError', message: 'Invalid primary key type Undefined for table exercises. Tables marked for sync has primary keys of type string or Array of string (and optional numbers)', inner: null}
(It fails pretty much for all tables, but in this case I tried to insert into exercises table).
I assume it has issue with $$ syntax. But how do I get around that? I really like using ulidx as primary key, they are very database friendly and also distributed systems friendly.
Metadata
Metadata
Assignees
Labels
No labels