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

TypeScript mongoose.connection类代码示例

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

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



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

示例1: resolve

    return new Promise<DatabaseObject>((resolve, reject) => {
      mongoose.connect(uri, config)

      mongoose.connection.once('connected', () => {
        logger.info('database connection: success')

        resolve({
          alert: AlertModel,
          attachment: AttachmentModel,
          connection: mongoose.connection,
          delivery: DeliveryModel,
          logger: logger,
          order: OrderModel,
          place: PlaceModel,
          product: ProductModel,
          stock: StockModel,
          tokenSalt: config.tokenSalt,
          user: UserModel
        })
      })

      mongoose.connection.on('error', (err) => {
        logger.error(`database error: ${err}`)
        if (! this.isResolved) {
          reject(err)
        }
      })

      mongoose.connection.on('disconnected', () => {
        logger.info('database connection: ended')
      })
    })
开发者ID:chipp972,项目名称:stock_manager_api,代码行数:32,代码来源:index.ts


示例2: connectMongo

 private connectMongo() {
     let connect = () => mongoose.connect(process.env.MONGO_URL);
     mongoose.connection.on('disconnected', connect);
     mongoose.connection.on('error', err => {
         Logger.errorLog(err);
     });
     connect();
 }
开发者ID:jgkim7,项目名称:blog,代码行数:8,代码来源:app.ts


示例3: async

module.exports = async (context, myBlob) => {
//export async function run (context, myBlob) {

    context.funcId = context.executionContext.invocationId;
    context.log(`ProcessId: ${context.funcId}`);

    try {
        mongoose.connect(process.env.MONGOLAB_URI, configs.mongoose);
        const rows: any = await readCsv(context);
        const entities  = await posRepo.getPosSales(rows);

        const errors = await posRepo.validation(entities, context);
        context.log(`${context.bindingData.name}ファイル: Number of lines appears error is ${errors.length}`);

        if (errors.length == 0) {
            const reservations = await getCheckins(entities, context);
            await posRepo.setCheckins(entities, reservations).then(async (docs) => {
                
                await posRepo.saveToPosSales(docs, context).then(async () => {
                    await posRepo.mergeFunc(context);
                });
            });
        } else {
            Logs.writeErrorLog(context, errors.join("\n"));
        }
        mongoose.connection.close();
    } catch (error) {
        context.log(error);
        Logs.writeErrorLog(context, `${context.bindingData.name}ファイル` + "\n" + error.stack);
    }
}
开发者ID:motionpicture,项目名称:ttts-functions,代码行数:31,代码来源:index.ts


示例4: init

    static init():void {
      const URL = (process.env.NODE_ENV === 'production') ? process.env.MONGOLAB_URI : dbConst.localhost;

      mongoose.connect(URL);
      mongoose.connection.on('error', console.error.bind(console, 'An error ocurred with the DB connection: '));

    }
开发者ID:kieranfraser,项目名称:sonard,代码行数:7,代码来源:db.conf.ts


示例5: function

process.on('SIGINT', function () {/////this function will run jst before app is closing
    console.log("app is terminating");
    mongoose.connection.close(function () {
        console.log('Mongoose default connection closed');
        process.exit(0);
    });
});
开发者ID:MUMARA,项目名称:UmrSalesmenAppLogoutCompleteNoConsoles3,代码行数:7,代码来源:index.ts


示例6: getCheckins

/**
 * //connect into mongoose to get checkins datas got it from previous step
 * @param conds Array
 * @param context Azure function of variable
 */
async function getCheckins (conds, context) {
    mongoose.connect(process.env.MONGOLAB_URI, configs.mongoose);
    const entities = await mongoose.model('Reservation')
        .find({ $or: conds },{checkins: true, payment_no: true, seat_code: true, performance_day: true}).exec()
        .then(docs => docs.map( doc => {
            
            doc.entry_flg = 'FALSE';
            doc.entry_date = null;

            if (doc.checkins.length >= 1) {
                doc.entry_flg = 'TRUE';
                doc.entry_date = doc.checkins[0].when.toISOString();
            }

            return '(' + [
                `'${doc.payment_no}'`
                , `'${doc.seat_code}'`
                , `'${doc.performance_day}'`
                , `'${doc.entry_flg}'`
                , doc.entry_date !== null ? `'${doc.entry_date}'` : `NULL`].join(',') + ')';
        }));

    mongoose.connection.close();
    return entities;
}
开发者ID:motionpicture,项目名称:ttts-functions,代码行数:30,代码来源:index.ts


示例7: after

after((done) => {
  // required because https://github.com/Automattic/mongoose/issues/1251#issuecomment-65793092
  mongoose.models = {};
  mongoose.modelSchemas = {};
  mongoose.connection.close();
  done();
});
开发者ID:eastmaels,项目名称:v2.api.utopian.io,代码行数:7,代码来源:user.test.ts


示例8: connect

    /**
     * Mongodb connection
     */
    public connect(error, callback) {

        Mongoose.connect(this.dburl, this.options);

        /** CONNECTION EVENTS */
        /** When successfully connected */
        Mongoose.connection.on("connected", function() {
            Logger.info("Mongoose connection open");
            callback();
        });

        /** If the connection throws an error */
        Mongoose.connection.on("error", function(err) {
            Logger.info("Mongoose default connection error: " + err);
            error(err);
        });
    }
开发者ID:nshahm,项目名称:generator-microservice-template,代码行数:20,代码来源:Mongodb.ts


示例9: config

    private config() {
        this.app.use(Middleware.configuration);

        mongoose.connection.once('open', () => {
            console.log('Connected to Mongoose at', environment.mongoConnectionString);
        });

        mongoose.connect(environment.mongoConnectionString);
    }
开发者ID:fedoranimus,项目名称:typescript-mean-stack,代码行数:9,代码来源:server.ts


示例10: _initializeDatabaseConnection

  private _initializeDatabaseConnection(test: boolean): void {
    winston.info("Initializing database connection");

    mongoose.connection.on("open", function(): void {
      winston.info("Database connection initialized");
    });

    mongoose.connection.on("error", function(): void {
      winston.error("Unable to connect to the database");
    });

    if (test) {
      mongoose.connect(`mongodb://${config.get("dbConfig.host")}:${config.get("dbConfig.port")}/${config.get("test.dbConfig.dbName")}`);
    }
    else {
      mongoose.connect(`mongodb://${config.get("dbConfig.host")}:${config.get("dbConfig.port")}/${config.get("dbConfig.dbName")}`);
    }
  }
开发者ID:guedjm,项目名称:StickItWebServer,代码行数:18,代码来源:StickItServer.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript .Types类代码示例发布时间:2022-05-25
下一篇:
TypeScript mongoose-auto-increment.initialize函数代码示例发布时间: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