• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript mongoose.set函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Error

(async () => {
	try {
		logger.info(null, '[app] Starting up...');

		// validate settings
		if (!settings.validate()) {
			throw new Error('Settings validation failed.');
		}

		// bootstrap models
		logger.info(null, '[app] Connecting to MongoDB...');
		mongoose.set('useNewUrlParser', true);
		mongoose.set('useFindAndModify', false);
		mongoose.set('useCreateIndex', true);
		if (config.vpdb.dbLogging.writeQueries) {
			mongoose.set('debug', (collection: string, method: string, query: any, doc: any, options: any) => {
				if (!['find', 'findOne', 'findMany', 'createIndex', 'countDocuments', 'count'].includes(method)) {
					logger.debug(null, '[MongoDB]: %s.%s(%s, %s, %s)', collection, method, JSON.stringify(query), JSON.stringify(doc), JSON.stringify(options));
				}
			});
		}
		await mongoose.connect(config.vpdb.db, { useNewUrlParser: true });

		// bootstrap endpoints
		for (const endPoint of endPoints) {
			logger.info(null, '[app] Registering %s:', endPoint.name);
			await server.register(endPoint);
		}

		// global serializers
		state.serializers.Moderation = new ModerationSerializer();

		server.postRegister(endPoints);

		// setup ACLs
		await initAcls();

		// cleanup inactive storage
		logger.info(null, '[app] Cleaning up inactive storage files older than one week.');
		await FileUtil.cleanup(3600000 * 24 * 7);

		// go!
		server.start();

	} catch (err) {
		/* istanbul ignore next */
		logger.error(null, err);
	}
})();
开发者ID:freezy,项目名称:node-vpdb,代码行数:49,代码来源:index.ts


示例2:

      .then((connection) => {
        // Enabling mongoose debug mode if required
        mongoose.set("debug", config.db.debug);

        // Call callback FN
        if (callback) { callback(connection.db); }
      })
开发者ID:relevantmedia,项目名称:angular2_mean,代码行数:7,代码来源:mongoose.ts


示例3: function

 mongoose.connect(config.mongo.uri, config.mongo.options, function (err) {
   // Log Error
   if (err) {
     console.error(chalk.default.bold.red('Could not connect to MongoDB!'));
     observer.error(err);
   } else {
     // Enabling mongoose debug mode if required
     mongoose.set('debug', config.mongo.debug);
     
     observer.next();
     observer.complete();
   }
 });
开发者ID:projectSHAI,项目名称:expressgular2,代码行数:13,代码来源:index.ts


示例4: new

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
 */
var querystream: mongoose.QueryStream;
querystream.destroy(new Error());
querystream.pause();
开发者ID:RaySingerNZ,项目名称:DefinitelyTyped,代码行数:31,代码来源:mongoose-tests.ts


示例5: require

/// <reference path='../typings/node/node.d.ts' />
/// <reference path='../typings/mongodb/mongodb.d.ts' />
/// <reference path='../typings/express/express.d.ts' />

var mongoose = require('mongoose');

import options = require('./options-handler');
import log = require('./logger');

// Logs to debug every database query
mongoose.set('debug', options['database']['debug']);

var ObjectId = mongoose.Schema.Types.ObjectId;
var Mixed = mongoose.Schema.Types.Mixed;

// Ensures that the entry is a valid object ID
var isObjectId = function(n) {
  if (!n) {
    // Allow null/undefined
    return true;
  }

  if (typeof n.toString === 'function') {
    return mongoose.Types.ObjectId.isValid(n.toString());
  } else {
    return false;
  }
};

// Ensures that the entry is an array of valid object IDs
var isObjectIdArray = function(n) {
开发者ID:MisterTea,项目名称:TidalWave,代码行数:31,代码来源:model.ts


示例6: require

import * as express from 'express';
import * as helmet from 'helmet';
import * as morgan from 'morgan';
import * as mongoose from 'mongoose';
import {json, urlencoded} from 'body-parser';

const config = require('../../tradejs.config');
const app = express();
app.listen(config.server.email.port, () => console.log(`\n Email service started on      : 127.0.0.1:${config.server.email.port}`));

/**
 * mongo
 */
mongoose.set('debug', true);
mongoose.connection.on('error', console.error.bind(console, 'connection error:'));
mongoose.connection.once('open', function () {
	console.log('DB connected');
});
mongoose.connect(config.server.email.connectionString);

/**
 * express
 */
app.use(morgan('dev'));
app.use(helmet());
app.use(json());
app.use(urlencoded({extended: false}));
app.use((req, res, next) => {
	res.header('Access-Control-Allow-Origin', '*');
	res.header('Access-Control-Allow-Headers', '_id, Authorization, Origin, X-Requested-With, Content-Type, Accept');
	next();
开发者ID:Chegeek,项目名称:TradeJS,代码行数:31,代码来源:app.ts


示例7: require

// make bluebird default Promise
Promise = require('bluebird'); // eslint-disable-line no-global-assign

// plugin bluebird promise in mongoose
(mongoose as any).Promise = Promise;

// connect to mongo db
mongoose.connect(config.mongo, { server: { socketOptions: { keepAlive: 1 } } });
mongoose.connection.on('error', () => {
  throw new Error(`unable to connect to database`);
});

// print mongoose logs in dev env
if (config.mongooseDebug) {
  mongoose.set('debug', (collectionName, method, query, doc) => {
    debug(`${collectionName}.${method}`, util.inspect(query, false, 20), doc);
  });
}

// module.parent check is required to support mocha watch
// src: https://github.com/mochajs/mocha/issues/1912
if (!module.parent) {
  const port = config.server.port;
  if (config.server.cert && config.server.key) {
    const options = {
      cert: fs.readFileSync(config.server.cert),
      key: fs.readFileSync(config.server.key)
    };

    https.createServer(options, app).listen(port, () => {
      console.info(`server started on port ${port} (${config.env})`);
开发者ID:eastmaels,项目名称:v2.api.utopian.io,代码行数:31,代码来源:index.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript mongoose.Connection类代码示例发布时间:2022-05-25
下一篇:
TypeScript mongoose.plugin函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap