Spaces:
Sleeping
Sleeping
File size: 630 Bytes
5da61b4 cad3e14 1b66f8d cad3e14 067b52a 5da61b4 067b52a cad3e14 5da61b4 cad3e14 5da61b4 cad3e14 5da61b4 cad3e14 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import type { LayoutServerLoad } from "./$types";
import { collections } from "$lib/server/database";
import type { Conversation } from "$lib/types/Conversation";
export const load: LayoutServerLoad = async (event) => {
const { conversations } = collections;
return {
conversations: await conversations
.find({
sessionId: event.locals.sessionId,
})
.sort({ updatedAt: -1 })
.project<Pick<Conversation, "title" | "_id" | "updatedAt" | "createdAt">>({
title: 1,
_id: 1,
updatedAt: 1,
createdAt: 1,
})
.map((conv) => ({ id: conv._id.toString(), title: conv.title }))
.toArray(),
};
};
|