feat: uuid ids everywhere, pickers for linked tickets, @pi/ui checkboxes
- Postgres: every table has a uuid `id` (gen_random_uuid()); the event store keeps its relay order in `seq`, and the lookup tables their uniqueness in constraints of their own. - MongoDB: `_id` is Mongo's ObjectId; `id` is the domain id (the same uuid as the aggregate's stream in Postgres), unique, and every query goes by it. Production starts from empty databases. - Web: linking tickets and hanging one from a parent are picked from a searchable select (links across projects, parents within the project) instead of typing a key; every checkbox is @pi/ui's pi-checkbox. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,7 +26,7 @@ export class MongoNotificationsRepository extends NotificationsRepository {
|
||||
|
||||
async insert({ id, ...rest }: NotificationReadModel): Promise<boolean> {
|
||||
const result = await this.notifications.updateOne(
|
||||
{ _id: id },
|
||||
{ id },
|
||||
{ $setOnInsert: rest },
|
||||
{ upsert: true },
|
||||
);
|
||||
@@ -51,21 +51,21 @@ export class MongoNotificationsRepository extends NotificationsRepository {
|
||||
|
||||
async markRead(userId: string, ids: string[] | null): Promise<void> {
|
||||
await this.notifications.updateMany(
|
||||
{ userId, readAt: null, ...(ids ? { _id: { $in: ids } } : {}) },
|
||||
{ userId, readAt: null, ...(ids ? { id: { $in: ids } } : {}) },
|
||||
{ $set: { readAt: new Date().toISOString() } },
|
||||
);
|
||||
}
|
||||
|
||||
async settings(userId: string): Promise<NotificationSettingsReadModel> {
|
||||
const doc = await this.settingsDocs
|
||||
.findById(userId)
|
||||
.findOne({ id: userId })
|
||||
.lean<NotificationSettingsDoc>();
|
||||
return { userId, email: doc?.email ?? false };
|
||||
}
|
||||
|
||||
async saveSettings(settings: NotificationSettingsReadModel): Promise<void> {
|
||||
await this.settingsDocs.updateOne(
|
||||
{ _id: settings.userId },
|
||||
{ id: settings.userId },
|
||||
{ $set: { email: settings.email } },
|
||||
{ upsert: true },
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user