當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。