本文整理汇总了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) {
开发者ID:ghiscoding,项目名称:Realtime-TODO-Aurelia-RethinkDB,代码行数:31,代码来源:todo.controller.ts
示例2: RDash
import * as RDash from "rethinkdbdash";
const r = RDash({
db: "send2pocket",
host: process.env.RETHINKDB_HOST || "localhsot"
});
export default r;
开发者ID:spiffytech,项目名称:send2pocket,代码行数:7,代码来源:db.ts
示例3: connect
export function connect(connectionOptions: ConnectionOptions = config.rethinkdb) {
return r = rethinkdbdash(connectionOptions);
}
开发者ID:nawalgupta,项目名称:ng2-ui-auth-example,代码行数:3,代码来源:connect.ts
示例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) => { });
}
开发者ID:profikid,项目名称:rethinkdb-typescript-definition,代码行数:28,代码来源:rethinkdbdash-tests.ts
注:本文中的rethinkdbdash类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论