Socket
Socket
Sign inDemoInstall

nothinkdb

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nothinkdb

Functional toolkit for rethinkdb


Version published
Maintainers
1
Created
Source

npm version Build Status

Nothinkdb

Functional toolkit for rethinkdb.

  • handle schema validation with joi.
  • handle default fields like id, createdAt, updatedAt.
  • fully customizable 1-n, 1-1, n-1, n-m relations. (create, remove, join).
  • ensure table, secondary index.
  • ensure unique field.
  • many useful query generator.

Install

npm install -S nothinkdb

Example

import Joi from 'joi';
import { r, Table, schema } from 'nothinkdb';

const userTable = new Table({
  table: 'user',
  schema: () => ({
    id: schema.id,
    name: Joi.string().required(),
    isPremium: Joi.boolean().default(false),
  }),
});

async function run() {
  // open rethinkdb connection
  const connection = await r.connect({ db: 'test' });

  // sync table
  await userTable.sync(connection);

  // create user data
  const normalUser = userTable.create({ name: 'user1' });
  const premiumUser = userTable.create({ name: 'user2', isPremium: true });

  // insert user data into rethinkdb server
  await userTable.insert([
    normalUser,
    premiumUser,
  ]).run(connection);

  // getAll users
  const users = await userTable.query().coerceTo('array').run(connection);

  console.log(users);

  // close rethinkdb connection
  await connection.close();
}

run();

If you want to see more examples, See the Examples

API

See the API Reference.

Keywords

FAQs

Package last updated on 19 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc