本文整理汇总了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();
});
示例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) })
示例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')
})
示例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();
});
示例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
})
}
示例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();
});
}