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


TypeScript rethinkdb.connect函数代码示例

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


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

示例1: function

routerUnauthenticated.get("/bar/:barId", async function () {
    var conn = await r.connect(AppConfig.dbConfig);
    this.body = await r.table("locations")
        .get(this.params.barId)
        .run(conn);
    conn.close();
});
开发者ID:hhoechtl,项目名称:bar-sounds-hackathon,代码行数:7,代码来源:app.ts

示例2: catch

db.connect(async () => {
  console.log('rethink', settings.rethinkdb)
  let conn = await rethink.connect(settings.rethinkdb)
  var dbs = await rethink.dbList().run(conn)
  console.log(dbs)
  let fails = 0
  conn.use('icecondor')
  try {
    const cursor = await rethink.table('users').run(conn)
    const users = await cursor.toArray() // all at once
    for (const user of users) {
      try {
        const eu = await db.ensure_user(user)
        if (eu.error) {
          console.log('user2lmdb result error', eu.error)
        } else {
          if (user.id != eu.id) {
            console.log('user2lmdb save FAIL', user.email, eu.email)
            console.log('rethink user', user)
            console.log('ensure user', eu)
            fails += 1
          }
        }
      } catch (e) {
        console.log('user2lmdb', user.email, 'CATCH', e)
        process.exit(1)
      }
    }

    console.log('*** done', users.length, 'rethink users', fails, 'save fails')
    await db.schema_dump()
  } catch (e) {
    console.log(e)
  }
}).catch(e => { console.log(e); process.exit(1) })
开发者ID:icecondor,项目名称:api,代码行数:35,代码来源:rethink-users2lmdb.ts

示例3: Date

db.connect(async () => {
  console.log('rethink', settings.rethinkdb)
  let conn = await rethink.connect(settings.rethinkdb)
  var dbs = await rethink.dbList().run(conn)
  console.log(dbs)
  conn.use('icecondor')
  //  let act_total = await rethink.table('activities').count().run(conn)
  //  console.log('icecondor activities', act_total)

  try {
    let start = new Date(await db.activity_last_date() || "2008-08-01")
    let stop = new Date()
    while (stop) {
      console.log('\n** lmdb start', start)
      let time = new Date()
      stop = await pull_group(conn, start, limit)
      let delay_sec = (new Date().getTime() - time.getTime()) / limit
      console.log('group done', start, stop, delay_sec + "s", (limit / delay_sec).toFixed(0), "rows per sec")
      db.schema_dump()
      start = new Date(stop)
    }
  } catch (e) {
    console.log('while loop stopped:', e)
  }
  console.log('el fin')
})
开发者ID:icecondor,项目名称:api,代码行数:26,代码来源:rethink-activities2lmdb.ts

示例4: function

router.get("/api/messages", async function() {
  var conn = await r.connect(config.database);
  this.body = await r.table("messages")
                     .orderBy({index: r.desc("time")})
                     .limit(100).orderBy("time")
                     .run(conn);
  conn.close();
});
开发者ID:itainteasy,项目名称:angular2-typescript-example,代码行数:8,代码来源:app.ts

示例5: connect

export function connect () : Promise<db.Connection> {
    const host : string = settings.db.host.get()
    const port : number = settings.db.port.get()
    const name : string = settings.db.name.get()
    
    return db.connect({host, port})
        .then((conn) => {
            logger.debug(`RethinkDB connected to ${host}:${port}`)
            _conn = conn
            conn.use(name)
            logger.debug(`RethinkDB using database '${name}'`)
            return conn
        })
}
开发者ID:jpopesculian,项目名称:bc-reminder,代码行数:14,代码来源:db.ts

示例6: isomorphrendering

/*
    isomorphrendering() {
        const store = new FabaStore<IcommonStore>(commonImStore);

        const ev = new InitAccountEvent();
        ev.args = [];

        new InitAccountCommand(store).execute(ev);

        var k = React.createElement(Layout, {model: store.data, childs: ev.view});
        var h = ReactDOM.renderToString(k);
        var c = css();

        var testHtml = `<head><style>${c}</style><body>${h}</body>`;

        console.log(testHtml);
    }
*/
    async createDbConnection(): Promise<void> {
        r.connect({host: 'localhost', port: 28015}, (err, conn) => {
            if (err) throw err;
            dbConnection = conn;

            r.dbCreate('lingua').run(conn, (er, rtr) => {
                //console.log(er);
            });


            db = r.db('lingua');

            new PrepareTablesEvent().dispatch();
        });
    }
开发者ID:joergwasmeier,项目名称:lingua,代码行数:33,代码来源:A_Server.ts


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