當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript mongoose.modelNames函數代碼示例

本文整理匯總了TypeScript中mongoose.modelNames函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript modelNames函數的具體用法?TypeScript modelNames怎麽用?TypeScript modelNames使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了modelNames函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

 protected addModelDescriminator<T extends mongoose.Document>(
     parentModel: mongoose.Model<mongoose.Document>,
     modelName,
     schema: mongoose.Schema
 ) {
     return !_.includes(mongoose.modelNames(), modelName)
         ? parentModel.discriminator<T>(modelName, schema)
         : mongoose.model<T>(modelName);
 }
開發者ID:kmarecki,項目名稱:mongoose-repos,代碼行數:9,代碼來源:repository.ts

示例2: clearDatabase

export async function clearDatabase() {
  if (isProd()) {
    throw new Error("How about you stop calling clearDatabase in production!")
  }

  console.log("Clearing database")
  await mongoose.connection.dropDatabase()
  for (const modelName of mongoose.modelNames()) {
    const model = mongoose.model(modelName)
    await model.init()
  }
}
開發者ID:Majavapaja,項目名稱:Mursushakki,代碼行數:12,代碼來源:mongo.ts

示例3: function

  }
}).open('');
mongoose.createConnection('localhost', 'database', 3000).open('');
mongoose.createConnection('localhost', 'database', 3000, {
  user: 'larry',
  config: {
    autoIndex: false
  }
}).open('');
mongoose.disconnect(cb).then(cb).fulfill;
mongoose.get('test');
mongoose.model('Actor', new mongoose.Schema({
  name: String
}), 'collectionName', true).find({});
mongoose.model('Actor').find({});
mongoose.modelNames()[0].toLowerCase();
new (new mongoose.Mongoose()).Mongoose().connect('');
mongoose.plugin(cb, {}).connect('');
mongoose.set('test', 'value');
mongoose.set('debug', function(collectionName: any, methodName: any, arg1: any, arg2: any) {});
mongoose.STATES.hasOwnProperty('');
mongoose.connection.on('error', cb);
new mongoose.mongo.MongoError('error').stack;
mongoose.SchemaTypes.String;
mongoose.Types.ObjectId;
mongoose.version.toLowerCase();

/*
 * section querystream.js
 * http://mongoosejs.com/docs/api.html#querystream-js
 */
開發者ID:RaySingerNZ,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:mongoose-tests.ts


注:本文中的mongoose.modelNames函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。