INNER CODE UNIT · TypeScript

findOne

austin-starks/Promptimizer · src/models/context/index.ts:70

  static async findOne(id: ObjectId) {
    const model = await ContextModel.findOne({ _id: id }).exec();
    if (!model) {
      throw new Error("Context not found");
    }
    return new Context(model);
  }

  static async find() {
    const userContexts = await ContextModel.find({})
      .sort({ _id: -1 })
      .exec()
      .then((models) => models.map((model) => new Context(model)));
    const sharedContexts = [
      new Context({
        name: "dateContext",
        value: new Date().toISOString(),
      }),

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…