当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript mongoose.model函数代码示例

本文整理汇总了TypeScript中mongoose.model函数的典型用法代码示例。如果您正苦于以下问题:TypeScript model函数的具体用法?TypeScript model怎么用?TypeScript model使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了model函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: callback

			$addToSet: { following: to }
		}
	).exec(function (err) {
		if (err)
			return callback(err);

		callback(null, null);
	});
};

// authenticate input against database
OrderSchema.statics.unFollow = function (from, to, callback) {

	Order.update(
		{
			_id: from,
		},
		{
			$inc: { followingCount: -1 },
			$pull: { following: to }
		}
	).exec(function (err) {
		if (err)
			return callback(err);

		callback(null, null);
	});
};

export const Order = model('Order', OrderSchema);
开发者ID:Chegeek,项目名称:TradeJS,代码行数:30,代码来源:order.ts

示例2:

                    zip: String,
                    website: String,
                    latitude: Number,
                    longitude: Number
                }
            },
            date: Date,
            category: String,
            content: String
        }
    ],
    books: [
        {
            id: Number,
            isbn10: Number,
            isbn13: Number,
            title: String,
            category: String
        }
    ]
}

// userSchema.method['comparePassword'] = function(candidatePassword: String, cb: Function) {
//     bcrypt.compare(candidatePassword, this.password, function(err: Error, isMatch: Boolean) {
//         if (err) return cb(err);
//         cb(null, isMatch);
//     });
// };

export let User: mongoose.Model<IUser> = mongoose.model<IUser>('User', userSchema);
开发者ID:uqutub,项目名称:NodejsMySql,代码行数:30,代码来源:userModel.ts

示例3:

import * as mongoose from 'mongoose';

export interface IBlogModel extends app.i.IBlog, mongoose.Document{}


let blogSchema = new mongoose.Schema({
  title: { type: String, required: true },
  datePosted: { type: Number },
  body: { type: String, required: true },
  imageURL: { type: String, default: 'http://1.bp.blogspot.com/-Bsv5jXiALOk/UdXLHs5jwaI/AAAAAAAAIU0/JuhiK3PvL10/s541/kune-kune-piglets-stacked.jpg' },
  tags: String
});

export let Blog = mongoose.model<IBlogModel>('Blog', blogSchema);
开发者ID:triciatseng,项目名称:expert-fortnight,代码行数:14,代码来源:Blog.ts

示例4: require

var mongoose = require('mongoose');


var ThingSchema = new mongoose.Schema({
    userid: {
        type: String,
        required: true
    },
    expireAt: {
        type: Date,
        required: true,
        default: function() {
        // 60 seconds from now
        return new Date(new Date().valueOf() + 7260000);
    }
    }
});

// Expire at the time indicated by the expireAt field
ThingSchema.index({ expireAt: 1 }, { expireAfterSeconds : 0 });

export = mongoose.model('Recovery', ThingSchema);
开发者ID:SocialMovieNetwork,项目名称:SMP-Final,代码行数:22,代码来源:recovery.model.ts

示例5: function

PlatformSchema.pre('save', function(next: Function): void {
  let user = this

  // generate a salt then run callback
  if (user.isNew) {
    bcrypt
    .genSalt(10, (err: Error, salt: string) => {
      if (err) { return next(err) }

      // encrypt password with salt
      bcrypt.hash(user.password, salt, null, (err, hash) => {
        if (err) { return next(err) }

        // overwrite plain text password with encrypted password
        user.password = hash

        next()
      })
    })
  } else {
    UTIL.setUpdateTime(user, ['username', 'password', 'nickname', 'name', 'gender', 'mobile', 'email', 'pid', 'avatar', 'background', 'locale', 'city', 'country'])
    user.wasNew = user.isNew

    next()
  }
})

export { IPlatform }

export default model<IPlatform>('Platform', PlatformSchema)
开发者ID:yeegr,项目名称:SingularJS,代码行数:30,代码来源:PlatformModel.ts

示例6: Schema

import { Schema, model } from 'mongoose';
const JobSchema = new Schema({
    companyName: {type: String, required: true},
    fantasyName: {type: String, required: true},
    cnpj: {type: String, required: true},
    showCompanyName: Boolean,
    opportunityName: {type: String, required: true},
    opportunityDecription: {type: String, required: true},
    howToSubscribe: {type: String, required: true},
    contact: {
        email: {type: String, required: true},
        name: {type: String, required: true},
        phone: {type: String, required: true}
    },
    salaryRange: {type: String, required: true},
    opportunityType: {type: String, required: true},
    contractType: {type: String, required: true},
    city: {type: String, required: true},
    state: {type: String, required: true}
});
export const Job = model('Job', JobSchema);
开发者ID:giggio,项目名称:transempregos-portal,代码行数:21,代码来源:job.ts

示例7: before

 before((done) => {
     User = mongoose.model("User");
     user = new User();
     done();
 })
开发者ID:cm0s,项目名称:mea2n,代码行数:5,代码来源:user.model.spec.ts

示例8:

import * as mongoose from 'mongoose';

export interface ICommentModel extends app.i.IComment, mongoose.Document{}

let commentSchema = new mongoose.Schema({
    message: {type: String, required: true},
    datePosted: Number,
    user: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true },
    event: {type: mongoose.Schema.Types.ObjectId, ref: 'Event', required: true}
});

export let Comment = mongoose.model<ICommentModel>('Comment', commentSchema);
开发者ID:aurbina83,项目名称:VC,代码行数:12,代码来源:model.ts

示例9:

import * as mongoose from 'mongoose';

export interface ITodoModel extends ITodo, mongoose.Document { }

let todoSchema = new mongoose.Schema({
  task: String,
  status: String,
});

export let Todo = mongoose.model('Todo', todoSchema);
开发者ID:benstelzer,项目名称:test,代码行数:10,代码来源:testing.model.ts

示例10: cb

        let user: IUser = users[0];
        user.compare(password, (bcryptErr, isAuth) => {
          if (bcryptErr) {
            cb(bcryptErr);
            return;
          }
          if (isAuth) {
            // remove the password from the fetched object
            delete user.password;
            cb(undefined, user);
            return;
          } else {
            cb(undefined, undefined);
          }
        });
      } else {
        cb(undefined, undefined);
      }
    });
  });
  
  userSchema.method('compare', function (password: string, cb: {(err: Error, isValid: boolean): void}): void {
    console.log('compare');
    bcrypt.compare(password, this.password, cb);
  });

  export const User: Model<IUser> = mongoose.model<IUser>('User', userSchema);

}
export = User;
开发者ID:dadakoko,项目名称:play-server,代码行数:30,代码来源:user.ts


注:本文中的mongoose.model函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。