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


TypeScript Connection.model方法代码示例

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


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

示例1: function

export default function(db: Connection): Model<Document> {
	const schema = new Schema({
		url: { type: String, required: true, unique: true }
	});

	return db.model('VisitHistory', schema, 'visitHistories');
}
开发者ID:syuilo,项目名称:ssmato.me,代码行数:7,代码来源:visit-history.ts

示例2: function

export default function(db: Connection): Model<Document> {
	const schema: any = new Schema({
		createdAt: { type: Date, required: true, default: Date.now },
		bio: { type: String, required: false, default: null },
		gender: { type: String, required: false, default: null },
		image: { type: Buffer, required: false, default: null },
		icon: { type: Buffer, required: false, default: null },
		color: { type: String, required: false, default: '#000000' },
		kana: { type: String, required: true },
		name: { type: String, required: true },
		ruby: { type: String, required: false, default: null },
		screenName: { type: String, required: true },
		aliases: [{ type: String, required: false, default: null }],
		series: [{ type: Schema.Types.ObjectId, required: true, ref: 'Series' }],
		ssCount: { type: Number, required: false, default: 0 }
	});

	if (!schema.options.toObject) {
		schema.options.toObject = {};
	}
	schema.options.toObject.transform = (doc: any, ret: any) => {
		ret.id = doc.id;
		delete ret._id;
		delete ret.__v;
	};

	return db.model('Character', schema, 'characters');
}
开发者ID:syuilo,项目名称:ssmato.me,代码行数:28,代码来源:character.ts

示例3: function

export default function(db: Connection): Model<Document> {
	const schema = new Schema({
		app: { type: Schema.Types.ObjectId, required: false, default: null, ref: 'Application' },
		key: { type: String, required: true, unique: true },
		user: { type: Schema.Types.ObjectId, required: true, ref: 'User' }
	});

	return db.model('UserKey', schema, 'UserKeys');
}
开发者ID:Tosuke,项目名称:Misskey-API,代码行数:9,代码来源:user-key.ts

示例4: function

export default function(db: Connection): Model<Document> {
	const schema = new Schema({
		createdAt: { type: Date, required: true, default: Date.now },
		followee: { type: Schema.Types.ObjectId, required: true, ref: 'User' },
		follower: { type: Schema.Types.ObjectId, required: true, ref: 'User' }
	});

	return db.model('UserFollowing', schema, 'UserFollowings');
}
开发者ID:akionux,项目名称:Misskey-API,代码行数:9,代码来源:user-following.ts

示例5: function

export default function(db: Connection): Model<Document> {
	mongooseAutoIncrement.initialize(db);

	const schema = new Schema({
		createdAt: { type: Date, required: true, default: Date.now },
		cursor: { type: Number },
		followee: { type: Schema.Types.ObjectId, required: true, ref: 'User' },
		follower: { type: Schema.Types.ObjectId, required: true, ref: 'User' }
	});

	// Auto increment
	schema.plugin(mongooseAutoIncrement.plugin, {
		model: 'UserFollowing',
		field: 'cursor'
	});

	return db.model('UserFollowing', schema, 'UserFollowings');
}
开发者ID:Tosuke,项目名称:Misskey-API,代码行数:18,代码来源:user-following.ts

示例6: function

export default function(db: Connection): Model<Document> {
	const schema: any = new Schema({
		createdAt: { type: Date, required: true, default: Date.now },
		image: { type: Buffer, required: false, default: null },
		description: { type: String, required: false, default: null },
		title: { type: String, required: true, unique: true },
		kana: { type: String, required: true },
		aliases: [{ type: String, required: false, default: null }],
		ssCount: { type: Number, required: false, default: 0 }
	});

	if (!schema.options.toObject) {
		schema.options.toObject = {};
	}
	schema.options.toObject.transform = (doc: any, ret: any) => {
		ret.id = doc.id;
		delete ret._id;
		delete ret.__v;
	};

	return db.model('Series', schema, 'series');
}
开发者ID:syuilo,项目名称:ssmato.me,代码行数:22,代码来源:series.ts

示例7: function

 */
var conn1: mongoose.Connection = mongoose.createConnection('mongodb://user:pass@localhost:port/database');
conn1 = new mongoose.Connection(mongoose);
conn1.open('mongodb://localhost/test', 'myDb', 27017, {
  replset: null,
  config: {
    autoIndex: false
  }
}, function (err) {}).open('');
conn1.openSet('mongodb://localhost/test', 'db', {
  replset: null,
  mongos: true
}, function (err) {}).then(cb).catch(cb);
conn1.close().catch(function (err) {});
conn1.collection('name').$format(999);
conn1.model('myModel', new mongoose.Schema({}), 'myCol').find();
conn1.modelNames()[0].toLowerCase();
conn1.config.hasOwnProperty('');
conn1.db.bufferMaxEntries;
conn1.collections['coll'].$format(999);
conn1.readyState.toFixed();
conn1.useDb('myDb').useDb('');
mongoose.Connection.STATES.hasOwnProperty('');
/* inherited properties */
conn1.on('data', cb);
conn1.addListener('close', cb);

/*
 * section error/validation.js
 * http://mongoosejs.com/docs/api.html#error-validation-js
 */
开发者ID:RaySingerNZ,项目名称:DefinitelyTyped,代码行数:31,代码来源:mongoose-tests.ts

示例8: require

import {Connection, Document, Model} from "mongoose";
import {Constants} from "../config/Constants";
import Database = require("../databases/Database");
import {ICustomerDocument} from "./interfaces/ICustomerDocument";
import CustomerSchema = require("../databases/schemas/CustomerSchema");

let connection: Connection = Database.getConnectin();

// Define and export Mongoose.Model object
const customerModel: Model<Document> = connection.model<ICustomerDocument> ("Customer", CustomerSchema);
export = customerModel;
开发者ID:iammen,项目名称:crud-typescript-example,代码行数:11,代码来源:CustomerModel.ts

示例9: function

 */
var conn1: mongoose.Connection = mongoose.createConnection('mongodb://user:pass@localhost:port/database');
conn1 = new mongoose.Connection(mongoose);
conn1.open('mongodb://localhost/test', 'myDb', 27017, {
  replset: null,
  config: {
    autoIndex: false
  }
}, function (err) {}).open('');
conn1.openSet('mongodb://localhost/test', 'db', {
  replset: null,
  mongos: true
}, function (err) {}).then(cb).catch(cb);
conn1.close().catch(function (err) {});
conn1.collection('name').$format(999);
conn1.model('myModel', new mongoose.Schema({}), 'myCol').find();
interface IStatics {
  staticMethod1: (a: number) => string;
}
conn1.model<{}, IStatics>('').staticMethod1;
conn1.modelNames()[0].toLowerCase();
conn1.config.hasOwnProperty('');
conn1.db.bufferMaxEntries;
conn1.collections['coll'].$format(999);
conn1.readyState.toFixed();
conn1.useDb('myDb').useDb('');
mongoose.Connection.STATES.hasOwnProperty('');
/* inherited properties */
conn1.on('data', cb);
conn1.addListener('close', cb);
开发者ID:AlBlanc,项目名称:DefinitelyTyped,代码行数:30,代码来源:mongoose-tests.ts


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