本文整理匯總了TypeScript中mongoose.Promise.ES6方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Promise.ES6方法的具體用法?TypeScript Promise.ES6怎麽用?TypeScript Promise.ES6使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mongoose.Promise
的用法示例。
在下文中一共展示了Promise.ES6方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: Error
mongopromise.resolve(new Error('hi'), {}).resolve();
mongopromise.then(function (arg: any) {
arg.sparse(true);
}, function (err: any) {
err.stack;
}).then(function (arg1: any, arg2: any) {
arg1.sparse(true);
arg2.sparse(true);
});
mongopromise.complete(new mongoose.SchemaType('')).complete(
new mongoose.SchemaType(''),
new mongoose.SchemaType('')
);
/* static properties */
mongoose.Promise.ES6(function (complete: Function, error: Function) {
complete.apply(this);
error.apply(this);
});
/* inherited properties */
mongopromise.chain(mongopromise);
mongoose.Promise.FAILURE;
/* practical example */
mongoose.model('')
.findOne({})
.exec()
.then(function (arg) {
arg.save;
return 1;
}).then(function (num) {
num.toFixed;
return new Promise<string>((resolve, reject) => {
示例2: Error
mongopromise.on('init', cb).on('init', cb);
mongopromise.reject({}).reject('').reject(new Error('hi'));
mongopromise.resolve(new Error('hi'), {}).resolve();
mongopromise.then(function (arg) {
arg.toFixed();
return 9;
}, function (err) {
err.stack;
return 9;
}).then(function (arg1, arg2) {
arg1.toFixed();
arg2.toFixed();
});
mongopromise.complete();
/* static properties */
mongoose.Promise.ES6(function (complete: any, error: any) {
complete.apply(this);
error.apply(this);
});
/* Practical Examples */
interface IUser extends mongoose.Document {
name: string;
age: number;
}
var UserSchema = new mongoose.Schema({
name: String,
age: Number
});
var UserModel: mongoose.Model<IUser> = mongoose.model<IUser>('Model', UserSchema);
UserModel.findOne({}).exec().fulfill();
UserModel.find({}).exec().then(() => {}).catch(() => {}).reject('');