nsarrazin HF staff commited on
Commit
3c372b8
1 Parent(s): 03202d0

Only pull from settings where the assistant is present (#806)

Browse files
src/lib/server/database.ts CHANGED
@@ -67,6 +67,7 @@ client.on("open", () => {
67
  sharedConversations.createIndex({ hash: 1 }, { unique: true }).catch(console.error);
68
  settings.createIndex({ sessionId: 1 }, { unique: true, sparse: true }).catch(console.error);
69
  settings.createIndex({ userId: 1 }, { unique: true, sparse: true }).catch(console.error);
 
70
  users.createIndex({ hfUserId: 1 }, { unique: true }).catch(console.error);
71
  users.createIndex({ sessionId: 1 }, { unique: true, sparse: true }).catch(console.error);
72
  messageEvents.createIndex({ createdAt: 1 }, { expireAfterSeconds: 60 }).catch(console.error);
 
67
  sharedConversations.createIndex({ hash: 1 }, { unique: true }).catch(console.error);
68
  settings.createIndex({ sessionId: 1 }, { unique: true, sparse: true }).catch(console.error);
69
  settings.createIndex({ userId: 1 }, { unique: true, sparse: true }).catch(console.error);
70
+ settings.createIndex({ assistants: 1 }).catch(console.error);
71
  users.createIndex({ hfUserId: 1 }, { unique: true }).catch(console.error);
72
  users.createIndex({ sessionId: 1 }, { unique: true, sparse: true }).catch(console.error);
73
  messageEvents.createIndex({ createdAt: 1 }, { expireAfterSeconds: 60 }).catch(console.error);
src/routes/settings/assistants/[assistantId]/+page.server.ts CHANGED
@@ -33,7 +33,9 @@ export const actions: Actions = {
33
 
34
  // and remove it from all users settings
35
  await collections.settings.updateMany(
36
- {},
 
 
37
  {
38
  $pull: { assistants: assistant._id },
39
  }
 
33
 
34
  // and remove it from all users settings
35
  await collections.settings.updateMany(
36
+ {
37
+ assistants: { $in: [assistant._id] },
38
+ },
39
  {
40
  $pull: { assistants: assistant._id },
41
  }