@architect/data
Advanced tools
Comparing version 2.0.1 to 2.0.2
31
_init.js
@@ -1,8 +0,3 @@ | ||
var fs = require('fs') | ||
var path = require('path') | ||
var aws = require('aws-sdk') | ||
var _db = require('./db') | ||
var _doc = require('./doc') | ||
var parse = require('@architect/parser') | ||
var exists = require('file-exists') | ||
var pfy = require('./_promisify-object') | ||
@@ -15,3 +10,3 @@ var testing = typeof process.env.NODE_ENV === 'undefined' || process.env.NODE_ENV === 'testing' | ||
module.exports = function _init(arc) { | ||
var app = arc.app[0] | ||
@@ -33,3 +28,3 @@ | ||
params.Key = key | ||
_doc.delete(params, callback) | ||
_doc.delete(params, callback) | ||
}, | ||
@@ -43,3 +38,3 @@ get(key, callback) { | ||
else callback(null, result.Item) | ||
}) | ||
}) | ||
}, | ||
@@ -50,28 +45,28 @@ put(item, callback) { | ||
params.Item = item | ||
_doc.put(params, function _put(err, result) { | ||
_doc.put(params, function _put(err) { | ||
if (err) callback(err) | ||
else callback(null, item) | ||
}) | ||
else callback(null, item) | ||
}) | ||
}, | ||
query(params, callback) { | ||
params.TableName = TableName | ||
_doc.query(params, callback) | ||
_doc.query(params, callback) | ||
}, | ||
scan(params, callback) { | ||
params.TableName = TableName | ||
_doc.scan(params, callback) | ||
_doc.scan(params, callback) | ||
}, | ||
update(params, callback) { | ||
params.TableName = TableName | ||
_doc.update(params, function _update(err, result) { | ||
_doc.update(params, function _update(err) { | ||
if (err) callback(err) | ||
else callback() | ||
}) | ||
else callback() | ||
}) | ||
} | ||
})) | ||
// builds out a data layer object | ||
var layer = {} | ||
// add _name, _db and _doc helper shortcuts | ||
// add _name, _db and _doc helper shortcuts | ||
Object.defineProperty(layer, '_name', { | ||
@@ -78,0 +73,0 @@ enumerable: false, |
@@ -10,3 +10,3 @@ var aws = require('aws-sdk') | ||
if (testing) { | ||
if (testing) { | ||
aws.config.update({ | ||
@@ -13,0 +13,0 @@ region: 'us-west-1' |
@@ -10,3 +10,3 @@ var aws = require('aws-sdk') | ||
if (testing) { | ||
if (testing) { | ||
aws.config.update({ | ||
@@ -13,0 +13,0 @@ region: 'us-west-1' |
@@ -6,5 +6,5 @@ var fs = require('fs') | ||
var init = require('./_init') | ||
// path to the .arc for hydration | ||
var arcPath | ||
var arcPath | ||
@@ -22,3 +22,3 @@ // see if we are testing @architect/data itself | ||
} | ||
// if this module is required and cannot find .arc it will blow up | ||
@@ -29,5 +29,5 @@ var notFound = !exists(arcPath) | ||
// returns a client for the .arc | ||
// returns a client for the .arc | ||
var arc = parse(fs.readFileSync(arcPath).toString()) | ||
module.exports = init(arc) |
var fs = require('fs') | ||
var path = require('path') | ||
var aws = require('aws-sdk') | ||
var _db = require('./db') | ||
var _doc = require('./doc') | ||
var parse = require('@architect/parser') | ||
var exists = fs.existsSync | ||
var pfy = require('./_promisify-object') | ||
var init = require('./_init') | ||
@@ -16,3 +12,3 @@ | ||
module.exports = function data(p) { | ||
// reads .arc from cwd | ||
@@ -19,0 +15,0 @@ var arcPath = typeof p != 'undefined'? p : path.join(process.cwd(), '.arc') |
{ | ||
"name": "@architect/data", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Dynamically generate a DynamoDB data access layer from an .arc file", | ||
@@ -8,2 +8,3 @@ "main": "index.js", | ||
"test": "NODE_ENV=testing ARC_LOCAL=yas tape 'test/*-test.js' | tap-spec", | ||
"lint": "eslint . --fix --ignore-pattern node_modules", | ||
"start": "NODE_ENV=testing ARC_LOCAL=yas node repl" | ||
@@ -26,2 +27,3 @@ }, | ||
"aws-sdk": "^2.106.0", | ||
"eslint": "^4.19.1", | ||
"run-parallel": "^1.1.6", | ||
@@ -28,0 +30,0 @@ "tap-spec": "^4.1.1", |
@@ -8,6 +8,6 @@ #!/usr/bin/env node | ||
var db = workflows.sandbox.db.start(x=> { | ||
var db = workflows.sandbox.db.start(function _start() { | ||
var server = repl.start({prompt}) | ||
server.context.data = data | ||
server.on('exit', x=> db.close()) | ||
server.on('exit', db.close) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11104
10
213
13
6