當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript rethinkdbdash類代碼示例

本文整理匯總了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;未經允許,請勿轉載。