arangolize
Advanced tools
Comparing version 0.9.3 to 0.9.4
@@ -96,3 +96,19 @@ "use strict"; | ||
} else { | ||
query(` return MERGE(instance, { @includeAs: DOCUMENT(instance[@includeAs]) }) \n), \n`); | ||
query(`let doc = MERGE(instance, { @includeAs: DOCUMENT(instance[@includeAs]) })`); | ||
if (include.where) { | ||
Object.keys(include.where).map((key, index) => { | ||
const variable = `${key}${index}`; | ||
const value = `${variable}value`; | ||
bindVars({ | ||
[variable]: key | ||
}); | ||
bindVars({ | ||
[value]: include.where[key] | ||
}); | ||
query(`\n filter doc.@includeAs.@${variable} == @${value}`); | ||
}); | ||
} | ||
query(`\n return doc)\n`); | ||
} | ||
@@ -149,16 +165,3 @@ } | ||
query` return instance ) \n`; // ends data = (...) | ||
query` return { | ||
data: ( | ||
for instance in data | ||
limit @skip, @limit | ||
`; | ||
if (attributes && !include) { | ||
bindVars({ | ||
attributes: attributes | ||
}); | ||
query` return KEEP(instance, @attributes) \n ), \n`; | ||
} else if (attributes && include) { | ||
if (attributes && include) { | ||
query`let atts = KEEP(instance, @attributes)`; | ||
@@ -169,8 +172,13 @@ | ||
_this.handleInclude(); | ||
} else { | ||
query` return instance ), \n`; | ||
} | ||
query` meta: { count: LENGTH(data) }`; | ||
query` \n }`; | ||
query` return { | ||
data: ( | ||
for instance in data | ||
limit @skip, @limit | ||
return instance | ||
), | ||
meta: { count: LENGTH(data) } | ||
} | ||
`; | ||
return { | ||
@@ -177,0 +185,0 @@ query: _this._query, |
42
index.js
@@ -76,3 +76,15 @@ import { autobind } from 'core-decorators' | ||
} else { | ||
query(` return MERGE(instance, { @includeAs: DOCUMENT(instance[@includeAs]) }) \n), \n`) | ||
query(`let doc = MERGE(instance, { @includeAs: DOCUMENT(instance[@includeAs]) })`) | ||
if (include.where) { | ||
Object.keys(include.where).map((key, index) => { | ||
const variable = `${key}${index}` | ||
const value = `${variable}value` | ||
bindVars({[variable]: key}) | ||
bindVars({[value]: include.where[key]}) | ||
query(`\n filter doc.@includeAs.@${variable} == @${value}`) | ||
}) | ||
} | ||
query(`\n return doc)\n`) | ||
} | ||
@@ -82,3 +94,3 @@ } | ||
async build () { | ||
let { where, attributes, sort, include } = this.props | ||
let { where, attributes, sort, include} = this.props | ||
const { query, bindVars } = this | ||
@@ -110,13 +122,3 @@ | ||
query` return instance ) \n` // ends data = (...) | ||
query` return { | ||
data: ( | ||
for instance in data | ||
limit @skip, @limit | ||
` | ||
if (attributes && !include) { | ||
bindVars({ attributes: attributes }) | ||
query` return KEEP(instance, @attributes) \n ), \n` | ||
} else if (attributes && include) { | ||
if (attributes && include) { | ||
query`let atts = KEEP(instance, @attributes)` | ||
@@ -126,10 +128,14 @@ this.handleInclude() | ||
this.handleInclude() | ||
} else { | ||
query` return instance ), \n` | ||
} | ||
query` meta: { count: LENGTH(data) }` | ||
query` return { | ||
data: ( | ||
for instance in data | ||
limit @skip, @limit | ||
return instance | ||
), | ||
meta: { count: LENGTH(data) } | ||
} | ||
` | ||
query` \n }` | ||
return { query: this._query, bindVars: this._bindVars } | ||
@@ -136,0 +142,0 @@ } |
@@ -17,1 +17,16 @@ import test from 'tape' | ||
}) | ||
/**/ | ||
test('should return query and bindVars', async (t) => { | ||
const { bindVars, query } = await arangolize({ | ||
collection: 'test', | ||
include: { | ||
as: 'user', | ||
where: { name: 'Noah', createdAt: "2017-09-05T12:05:30.166Z" } | ||
} | ||
}) | ||
t.ok(bindVars, 'should have bindVars') | ||
t.ok(query, 'should have query') | ||
t.end() | ||
}) |
{ | ||
"name": "arangolize", | ||
"version": "0.9.3", | ||
"version": "0.9.4", | ||
"description": "Sequelize-like query-builder for ArangoDB", | ||
@@ -11,3 +11,4 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"prepublish": "./node_modules/.bin/babel index.js -d ./dist --ignore node_modules/ --ignore dist/" | ||
"prepublish": "./node_modules/.bin/babel index.js -d ./dist --ignore node_modules/ --ignore dist/", | ||
"test": "./node_modules/.bin/tape -r @babel/register index.test.js" | ||
}, | ||
@@ -19,4 +20,10 @@ "devDependencies": { | ||
"@babel/preset-env": "^7.0.0-beta.37", | ||
"@babel/preset-stage-0": "^7.0.0-beta.37" | ||
"@babel/preset-stage-0": "^7.0.0-beta.37", | ||
"@babel/register": "^7.0.0-beta.39", | ||
"tape": "^4.8.0" | ||
}, | ||
"dependencies": { | ||
"@babel/register": "^7.0.0-beta.39", | ||
"core-decorators": "^0.20.0" | ||
} | ||
} |
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
90890
7
324
2
7
+ Addedcore-decorators@^0.20.0
+ Added@ampproject/remapping@2.3.0(transitive)
+ Added@babel/code-frame@7.26.2(transitive)
+ Added@babel/compat-data@7.26.2(transitive)
+ Added@babel/core@7.26.0(transitive)
+ Added@babel/generator@7.26.2(transitive)
+ Added@babel/helper-compilation-targets@7.25.9(transitive)
+ Added@babel/helper-module-imports@7.25.9(transitive)
+ Added@babel/helper-module-transforms@7.26.0(transitive)
+ Added@babel/helper-string-parser@7.25.9(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/helper-validator-option@7.25.9(transitive)
+ Added@babel/helpers@7.26.0(transitive)
+ Added@babel/parser@7.26.2(transitive)
+ Added@babel/register@7.25.9(transitive)
+ Added@babel/template@7.25.9(transitive)
+ Added@babel/traverse@7.25.9(transitive)
+ Added@babel/types@7.26.0(transitive)
+ Added@jridgewell/gen-mapping@0.3.5(transitive)
+ Added@jridgewell/resolve-uri@3.1.2(transitive)
+ Added@jridgewell/set-array@1.2.1(transitive)
+ Added@jridgewell/sourcemap-codec@1.5.0(transitive)
+ Added@jridgewell/trace-mapping@0.3.25(transitive)
+ Addedbrowserslist@4.24.2(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedcaniuse-lite@1.0.30001680(transitive)
+ Addedclone-deep@4.0.1(transitive)
+ Addedcommondir@1.0.1(transitive)
+ Addedconvert-source-map@2.0.0(transitive)
+ Addedcore-decorators@0.20.0(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addedelectron-to-chromium@1.5.62(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedfind-cache-dir@2.1.0(transitive)
+ Addedfind-up@3.0.0(transitive)
+ Addedgensync@1.0.0-beta.2(transitive)
+ Addedglobals@11.12.0(transitive)
+ Addedis-plain-object@2.0.4(transitive)
+ Addedisobject@3.0.1(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjsesc@3.0.2(transitive)
+ Addedjson5@2.2.3(transitive)
+ Addedkind-of@6.0.3(transitive)
+ Addedlocate-path@3.0.0(transitive)
+ Addedlru-cache@5.1.1(transitive)
+ Addedmake-dir@2.1.0(transitive)
+ Addedms@2.1.3(transitive)
+ Addednode-releases@2.0.18(transitive)
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@3.0.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedpath-exists@3.0.0(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpify@4.0.1(transitive)
+ Addedpirates@4.0.6(transitive)
+ Addedpkg-dir@3.0.0(transitive)
+ Addedsemver@5.7.26.3.1(transitive)
+ Addedshallow-clone@3.0.1(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsource-map-support@0.5.21(transitive)
+ Addedupdate-browserslist-db@1.1.1(transitive)
+ Addedyallist@3.1.1(transitive)