-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.ts
More file actions
38 lines (35 loc) · 1.3 KB
/
Copy pathdb.ts
File metadata and controls
38 lines (35 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import Dexie, { type EntityTable } from 'dexie';
import type { AppSettings, DailyEntry, LifeEventRecord, MonthlyReview, ResultRecord, WeeklyReview } from '@/types';
class TrajectoryDatabase extends Dexie {
dailyEntries!: EntityTable<DailyEntry, 'date'>;
results!: EntityTable<ResultRecord, 'id'>;
lifeEvents!: EntityTable<LifeEventRecord, 'id'>;
weeklyReviews!: EntityTable<WeeklyReview, 'weekStart'>;
monthlyReviews!: EntityTable<MonthlyReview, 'monthStart'>;
settings!: EntityTable<AppSettings, 'id'>;
constructor() {
super('trajectory-demo');
this.version(1).stores({
dailyEntries: '&date, updatedAt, careerState',
results: '++id, date, area, createdAt',
weeklyReviews: '&weekStart',
settings: '&id',
});
this.version(2).stores({
dailyEntries: '&date, updatedAt, careerState',
results: '++id, date, area, createdAt',
lifeEvents: '++id, date, type, createdAt',
weeklyReviews: '&weekStart',
settings: '&id',
});
this.version(3).stores({
dailyEntries: '&date, updatedAt, careerState',
results: '++id, date, area, createdAt',
lifeEvents: '++id, date, type, createdAt',
weeklyReviews: '&weekStart',
monthlyReviews: '&monthStart',
settings: '&id',
});
}
}
export const db = new TrajectoryDatabase();