Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

409 B
Raw Blame
const mongoose = require('mongoose');

const originalExec = mongoose.Query.prototype.exec;
mongoose.Query.prototype.exec = async function serialUserReads(...args) {
  if (this.model.collection.name === 'messages' && this.op === 'find') {
    for (let i = 0; i < 16; i++) {
      await mongoose.model('User').findById(this.getFilter().user).lean().exec();
    }
  }
  return originalExec.apply(this, args);
};