本文整理汇总了TypeScript中rethinkdbdash类的典型用法代码示例。如果您正苦于以下问题:TypeScript rethinkdbdash类的具体用法?TypeScript rethinkdbdash怎么用?TypeScript rethinkdbdash使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了rethinkdbdash类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: rethinkdbdash
import * as parse from 'co-body';
import { config } from '../../config';
import * as _ from 'lodash';
import * as Router from 'koa-router';
import * as rethinkdb from 'rethinkdb';
import * as rethinkdbdash from 'rethinkdbdash';
// RethinkDB table & reQl instance
const TABLE_NAME = 'todos';
const r: any = rethinkdbdash(config.rethinkdb);
// Retrieve all todo items
export const getAll = async (ctx: Router.IRouterContext, next: () => void) => {
try {
const userId = ctx.state.userId;
if (!userId) {
ctx.throw(400, 'userId required');
}
const result = await r.table(TABLE_NAME).filter({ userId }).orderBy('createdAt');
ctx.body = JSON.stringify(result);
} catch (e) {
ctx.status = e.status || 500;
ctx.body = e.message;
}
};
// Retrieve all todo items non-archived
export const getAllNonArchived = async (ctx: Router.IRouterContext, next: () => void) => {
try {
const userId = ctx.state.userId;
if (!userId) {
示例2: RDash
import * as RDash from "rethinkdbdash";
const r = RDash({
db: "send2pocket",
host: process.env.RETHINKDB_HOST || "localhsot"
});
export default r;
示例3: connect
export function connect(connectionOptions: ConnectionOptions = config.rethinkdb) {
return r = rethinkdbdash(connectionOptions);
}
示例4: test
/// <reference path="rethinkdbdash.d.ts" />
import * as rConnect from 'rethinkdbdash';
var r = rConnect({db: 'test'});
async function test() {
let connection = await r.connect('host');
r.db('something').table<{ id:string, name:string }>('great').get('a').run(connection, (err, result) => {
let id = result.id;
});
let instance = await r.db('something').table<{ id:string, name:string }>('great').get('a');
let changes = await r.db('something').table<{ id:string, name:string }>('great').get('a').changes();
changes.each((err, el) => console.log(el));
let eqJoin = await r.db('something').table<{ id:string, name:string }>('great').eqJoin('left', r.db('that').table<{ num:number }>('other'));
eqJoin.eachAsync(el => {
el.left.id;
el.right.num;
});
let a = 123;
let b = await r.db('something').table<{ id:string, name:string }>('great').get('123')<{ something:boolean }>('subObject');
let del = await r.db('something').table('a').delete({durability: 'hard'});
let del2 = await r.db('something').table('a').get('123').replace((current) => { });
}