Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 - npm Package Compare versions

Comparing version 0.5.29 to 0.5.30

lib/__tests__/Environment-test.js

11

lib/Environment.js

@@ -11,6 +11,2 @@ 'use strict';

var _promise = require('babel-runtime/core-js/promise');
var _promise2 = _interopRequireDefault(_promise);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');

@@ -36,5 +32,3 @@

function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -68,2 +62,3 @@ /* eslint no-shadow: 0 */

if (this.hasTable(tableName)) {

@@ -104,3 +99,3 @@ debug('[createTable] tableName: \'' + tableName + '\' is already defined');

_context3.next = 2;
return _promise2.default.all(_lodash2.default.map(this.tables, function () {
return Promise.all(_lodash2.default.map(this.tables, function () {
var ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(table) {

@@ -107,0 +102,0 @@ return _regenerator2.default.wrap(function _callee2$(_context2) {

@@ -19,5 +19,3 @@ 'use strict';

function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -24,0 +22,0 @@ var Link = function () {

@@ -15,5 +15,3 @@ 'use strict';

function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -20,0 +18,0 @@ var schema = {

@@ -7,6 +7,2 @@ 'use strict';

var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _extends3 = require('babel-runtime/helpers/extends');

@@ -16,6 +12,2 @@

var _promise = require('babel-runtime/core-js/promise');
var _promise2 = _interopRequireDefault(_promise);
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');

@@ -41,2 +33,6 @@

var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _rethinkdb = require('rethinkdb');

@@ -62,8 +58,15 @@

function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var debug = require('debug')('nothinkdb'); /* eslint no-shadow: 0, no-param-reassign: 0 */
function parseRelationOptions(options) {
return _lodash2.default.chain(options).omitBy(function (value, key) {
return !_lodash2.default.startsWith(key, '_');
}).reduce(function (memo, value, key) {
return (0, _defineProperty3.default)({}, key.slice(1), value);
}, {}).value();
}
var Table = function () {

@@ -92,2 +95,3 @@ function Table() {

this.tableName = tableName;

@@ -207,13 +211,14 @@ this.pk = pk;

case 0:
_context.next = 2;
debug('sync ' + connection.db + '.' + this.tableName + '...');
_context.next = 3;
return this.ensureTable(connection);
case 2:
_context.next = 4;
case 3:
_context.next = 5;
return this.ensureAllIndexes(connection);
case 4:
debug('[sync] ' + connection.db + '.' + this.tableName);
case 5:
debug('[done] sync ' + connection.db + '.' + this.tableName);
case 5:
case 6:
case 'end':

@@ -240,6 +245,10 @@ return _context.stop();

case 0:
_context2.next = 2;
debug('ensureTable ' + connection.db + '.' + this.tableName + '...');
_context2.next = 3;
return _rethinkdb2.default.branch(_rethinkdb2.default.tableList().contains(this.tableName).not(), _rethinkdb2.default.tableCreate(this.tableName), null).run(connection);
case 2:
case 3:
debug('[done] ensureTable ' + connection.db + '.' + this.tableName);
case 4:
case 'end':

@@ -269,4 +278,5 @@ return _context2.stop();

case 0:
debug('ensureAllIndex ' + connection.db + '.' + this.tableName + '...');
indexFields = [].concat((0, _toConsumableArray3.default)(this.metaFields('index')), (0, _toConsumableArray3.default)(this.metaFields('unique')));
_context3.next = 3;
_context3.next = 4;
return indexFields.reduce(function (promise, indexName) {

@@ -276,6 +286,6 @@ return promise.then(function () {

});
}, _promise2.default.resolve());
}, Promise.resolve());
case 3:
_context3.next = 5;
case 4:
_context3.next = 6;
return _lodash2.default.reduce(this.index, function (promise, option, indexName) {

@@ -285,5 +295,8 @@ return promise.then(function () {

});
}, _promise2.default.resolve());
}, Promise.resolve());
case 5:
case 6:
debug('[done] ensureAllIndex ' + connection.db + '.' + this.tableName);
case 7:
case 'end':

@@ -310,4 +323,6 @@ return _context3.stop();

case 0:
debug('ensureIndex ' + connection.db + '.' + this.tableName + ' ' + indexName + '...');
if (!(this.pk === indexName)) {
_context4.next = 2;
_context4.next = 3;
break;

@@ -318,11 +333,14 @@ }

case 2:
_context4.next = 4;
case 3:
_context4.next = 5;
return _rethinkdb2.default.branch(this.query().indexList().contains(indexName).not(), this.query().indexCreate(indexName, option), null).run(connection);
case 4:
_context4.next = 6;
case 5:
_context4.next = 7;
return this.query().indexWait(indexName).run(connection);
case 6:
case 7:
debug('[done] ensureIndex ' + connection.db + '.' + this.tableName + ' ' + indexName);
case 8:
case 'end':

@@ -469,3 +487,3 @@ return _context4.stop();

var index = relation.index(pk);
return relation.query(index, options);
return relation.query(index, parseRelationOptions(options));
}

@@ -472,0 +490,0 @@ }, {

{
"name": "nothinkdb",
"version": "0.5.29",
"version": "0.5.30",
"description": "Functional toolkit for rethinkdb",
"main": "lib/nothinkdb.js",
"main": "lib",
"files": [

@@ -10,4 +10,4 @@ "lib"

"scripts": {
"test": "mocha --compilers js:babel-register --timeout 20000 ./src/**/__tests__/*-test.js",
"build": "babel --ignore *-test.js -d lib src && babel -d lib lib",
"test": "mocha --compilers js:babel-register --timeout 20000 --recursive src/",
"build": "babel -d lib src",
"clean": "rimraf lib",

@@ -23,3 +23,6 @@ "lint": "eslint src",

"rethinkdb",
"orm"
"nothinkdb",
"functional",
"graphql",
"relay"
],

@@ -47,3 +50,3 @@ "author": "ironhee <leechulhee95@gmail.com>",

"eslint-plugin-import": "^1.8.0",
"mocha": "^2.4.5",
"mocha": "^2.5.3",
"rethinkdb": "2.2.3",

@@ -50,0 +53,0 @@ "rimraf": "^2.5.1"

@@ -7,8 +7,13 @@ [![npm version](https://badge.fury.io/js/nothinkdb.svg)](https://badge.fury.io/js/nothinkdb) [![Build Status](https://travis-ci.org/ediket/nothinkdb.svg?branch=master)](https://travis-ci.org/ediket/nothinkdb)

Currently, Compitable with rethinkdb 2.2.x
- define declarative table schema.
- handle schema validation with [joi](https://github.com/hapijs/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.
- fully customizable 1-n, 1-1, n-1, n-m relations.
- __define__, __create__, __remove__, __check__, __query__, __join__ relations.
- many useful query generator.
- easily implement graphql server with [nothinkdb-graphql](https://github.com/ediket/nothinkdb-graphql)

@@ -25,6 +30,7 @@ ## Install

import Joi from 'joi';
import { r, Table, schema } from 'nothinkdb';
import r from 'rethinkdb';
import { Table, schema } from 'nothinkdb';
const userTable = new Table({
table: 'user',
tableName: 'user',
schema: () => ({

@@ -43,2 +49,3 @@ id: schema.id,

await userTable.sync(connection);
await followingTable.sync(connection);

@@ -73,1 +80,8 @@ // create user data

See the [API Reference](https://github.com/ediket/nothinkdb/blob/master/API.md).
Related Links
------------
- [rethinkdb](https://github.com/rethinkdb/rethinkdb)
- [nothinkdb-graphql](https://github.com/ediket/nothinkdb-graphql)
- [graphql-relay-rethinkdb-example](https://github.com/ediket/graphql-relay-rethinkdb-example)
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