INNER CODE UNIT · TypeScript

Context

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

class Context {
  _id?: ObjectId;
  name: string;
  value: string;

  constructor(obj: IContext) {
    this.validate(obj);
    this._id = obj._id;
    this.name = obj.name?.trim();
    this.value = obj.value;
  }

  async save() {
    if (this._id) {
      await ContextModel.updateOne({ _id: this._id }, this, { upsert: true });
      return;
    }
    const model = await ContextModel.create(this);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…