本文整理汇总了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);
}
示例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()
}
}
示例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
*/