You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

redink

Package Overview
Dependencies
Maintainers
2
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redink

RethinkDB ORM

2.0.0-beta.3
Source
npm
Version published
Maintainers
2
Created
Source

Redink

RethinkDB ORM

CircleCI codecov

Installation

$ npm install redink

Define schemas

import { schema, hasMany, hasOne, belongsTo } from 'redink';

export const user = schema('user', {
  attributes: {
    name: true,
    email: true,
    createdOn: true,
  },
  relationships: {
    blogs: hasMany('blog', 'author'),
    company: hasOne('company', 'employees'),
  },
});

export const blog = schema('blog', {
  attributes: {
    title: true,
    content: true,
    createdOn: true,
  },
  relationships: {
    author: belongsTo('user', 'blogs'),
  },
});

export const company = schema('company', {
  attributes: {
    name: true,
    street: true,
    city: true,
    state: true,
    zip: true,
  },
  relationships: {
    employees: hasMany('user', 'company'),
  },
});

Connect

import redink from 'redink';
import * as schemas from './schemas';

redink()

  // connect to the RethinkDB instance and register the schemas
  .connect({
    schemas,
    db: `${db}`,
    host: `${host}`,
    verbose: true,
  })

  // yay
  .then(() => console.log('Connected!'))

  // damn
  .catch(console.error);

Simple API

Comprehensive documentation coming soon.

import { model } from 'redink';

model('user').create({
  name: 'Von Miller',
  email: 'mvp@gmail.com',
  createdOn: Date.now(),
}).then(user => {
  // Resource
});

model('user').find({
  filter: { name: 'Von Miller' },
}).then(user => {
  // Resource
});

Keywords

RethinkDB

FAQs

Package last updated on 12 Oct 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