Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .env

This file was deleted.

4 changes: 4 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CACHE_MGR_PATH=/usr/local/Cache/mgr
CACHE_USERNAME=
CACHE_PASSWORD=
CACHE_NAMESPACE=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
npm-debug.log
node_modules/
package-lock.json
*.lock

# Sublime Text
*.sublime-*
Expand Down
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
language: node_js
node_js:
- '11'
- '10'
- '9'
- '8'
- '7'
- '6'
- '5'
- '4'
- 'iojs'
- '0.12'
- '0.11'
- '0.10'
script:
- npm run test:unit
after_success:
Expand Down
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,34 @@ Google Group for discussions, support, advice etc: [http://groups.google.co.uk/g

## Integration tests

### Memory

* `npm run test:integration` (default)
* `npm run test:integration:memory`

### Redis

* `redis-server` (don't forget to start redis server)
* `npm run test:integration:redis`

### InterSystem Caché

* You must have [InterSystem Caché](http://www.intersystems.com/our-products/cache/cache-overview/) installed
* You must have `cache.node` in npm global registy. Read [Installation](http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=BXJS_intro#BXJS_intro_install) to get more details
* Run `npm link cache.node` before running integration tests
* You may need to run this as sudo because of permissions
* Run `npm run test:integration:cache`

### Gtm or YottaDb
* `cd ./docker/gtm`
* `docker build -t <name> .`
* `docker run -it --rm -v ~/path/to/ewd-document-store:/opt/qewd/mapped <name> /bin/bash`
* `cd mapped && npm run test:integration:gtm`


## License

Copyright (c) 2013-17 M/Gateway Developments Ltd,
Copyright (c) 2013-19 M/Gateway Developments Ltd,
Reigate, Surrey UK.
All rights reserved.

Expand Down
2 changes: 2 additions & 0 deletions docker/gtm/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
node_modules
6 changes: 6 additions & 0 deletions docker/gtm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM rtweed/qewd-server

COPY ./entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh", "-l"]
35 changes: 35 additions & 0 deletions docker/gtm/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

export gtm_version=V6.3-004
export ydb_versionp=r1.24
export ydb_version=r124
export ydb_arch=x86_64

export ydb_path="${ydb_versionp}_${ydb_arch}"
export gtm_path="${gtm_version}_${ydb_arch}"

export ydb_retention=42
export gtm_retention=42
export LD_LIBRARY_PATH="/usr/local/lib/yottadb/${ydb_version}"
export ydb_log="/tmp/yottadb/${ydb_path}"
export gtm_log="/tmp/yottadb/${ydb_path}"
export gtm_repl_instance="/root/.yottadb/${ydb_path}/g/yottadb.repl"
export ydb_repl_instance="/root/.yottadb/${ydb_path}/g/yottadb.repl"
export ydb_gbldir="/root/.yottadb/${ydb_path}/g/yottadb.gld"
export ydb_etrap='Write:(0=$STACK) "Error occurred=",$ZStatus,!'
export ydb_dir="/root/.yottadb"
export gtmver=$gtm_path
export ydb_rel=$ydb_path
export gtmgbldir="/root/.yottadb/${ydb_path}/g/yottadb.gld"
export ydb_routines="/opt/qewd/node_modules/nodem/src /root/.yottadb/${ydb_path}/o*(/root/.yottadb/${ydb_path}/r /root/.yottadb/r) /usr/local/lib/yottadb/${ydb_version}/libyottadbutil.so"
export gtmroutines="/opt/qewd/node_modules/nodem/src /root/.yottadb/${ydb_path}/o*(/root/.yottadb/${ydb_path}/r /root/.yottadb/r) /usr/local/lib/yottadb/${ydb_version}/libyottadbutil.so"
export GTMCI="/opt/qewd/node_modules/nodem/resources/nodem.ci"
export ydb_ci="/opt/qewd/node_modules/nodem/resources/nodem.ci"
export gtmdir=/root/.fis-gtm
export gtm_etrap='Write:(0=$STACK) "Error occurred=",$ZStatus,!'
export ydb_tmp="/tmp/yottadb/${ydb_path}"
export gtm_tmp="/tmp/yottadb/${ydb_path}"
export gtm_dist="/usr/local/lib/yottadb/${ydb_version}"
export ydb_dist="/usr/local/lib/yottadb/${ydb_version}"

exec "$@"
3 changes: 3 additions & 0 deletions lib/proto/forEach.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ module.exports = function(callback) {
node = {global: this.documentName, subscripts: subs};
if (direction === 'forwards') {
seed = db.previous(node).result;
subs = this.path.slice(0);
subs.push(seed);
node = {global: this.documentName, subscripts: subs};
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/proto/forEachLeafNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
| limitations under the License. |
----------------------------------------------------------------------------

7 September 2017
9 October 2018

*/

Expand Down
21 changes: 0 additions & 21 deletions lib/proto/getDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@
21 January 2019
*/

/*

No longer needed - GT.M bug fixed

function removeDoubleQuotes(value, db) {
if (db.version().indexOf('GT.M') !== -1 && value.toString().indexOf('""') !== -1) {
value = value.split('""').join('"');
}
return value;
}
*/

const NON_EXISTENT = 0;
const LEAF_NODE = 1;
const NO_DATA_HAS_CHILDREN = 10;
Expand Down Expand Up @@ -104,12 +92,8 @@ module.exports = function(useArrays, offset) {
index = result;
if (isArray) index = index - offset;
defined = db.data(node).defined;
//if (defined === LEAF_NODE) {
if (defined === LEAF_NODE || defined === HAS_DATA_HAS_CHILDREN) {
document[index] = convert(db.get(node).data);
//if (document[index] === 'true') document[index] = true;
//if (document[index] === 'false') document[index] = false;
//document[index] = removeDoubleQuotes(document[index], db);
}
if (defined === NO_DATA_HAS_CHILDREN || defined === HAS_DATA_HAS_CHILDREN) {
document[index] = getSubnodes(node);
Expand Down Expand Up @@ -170,12 +154,7 @@ module.exports = function(useArrays, offset) {
do {
delete node.data;
node = db.next_node(node);
//data = node.data || '';
data = convert(node.data);
//if (typeof data === 'undefined') data = '';
//if (data === 'false') data = false;
//if (data === 'true') data = true;
//data = removeDoubleQuotes(data, db);
match = false;
if (node.defined !== NON_EXISTENT) match = isSubNode(signature, node.subscripts);
if (match) {
Expand Down
2 changes: 1 addition & 1 deletion lib/proto/increment.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = function() {
};
var node = this._node;
var value = documentStore.db.increment(node).data;
value = parseInt(value);
value = parseInt(value, 10);
enode.value = value;
documentStore.emit('afterSet', enode);
return value;
Expand Down
19 changes: 13 additions & 6 deletions lib/proto/setDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,29 @@
| limitations under the License. |
----------------------------------------------------------------------------

7 September 2017
9 October 2018

*/

module.exports = function(document, offset) {
var set = this._set;
var that = this;
var documentName = this.documentName;
if (!offset) offset = 0;

var set = function(value, node) {
that._set.call(that, value, node);
};

var setFast = function(obj, documentNode) {
var subs;
var i;
var j;
var node;
var value;

for (i in obj){
if (obj[i] === null || typeof obj[i] === 'undefined') obj[i] = '';

if (obj[i] instanceof Array) {
//console.log('Array! ' + JSON.stringify(obj[i]));
if (obj[i].length !== 0) {
Expand All @@ -52,27 +57,29 @@ module.exports = function(document, offset) {
subs.push(i);
subs.push(j + offset);
setFast(obj[i][j], {global: documentName, path: subs});
}
}
else {
value = obj[i][j];
if (value === null) value = '';
subs = documentNode.path.slice(0);
subs.push(i);
subs.push(j + offset);
node = {global: documentName, subscripts: subs};
set.call(that, value, node);
set(value, node);
}
}
}
}

if (typeof obj[i] !== 'object') {
value = obj[i];
if (value === null || typeof value === 'undefined') value = '';
subs = documentNode.path.slice(0);
subs.push(i);
node = {global: documentName, subscripts: subs};
set.call(that, value, node);
}
set(value, node);
}

if (obj[i] instanceof Object && !(obj[i] instanceof Array)) {
subs = documentNode.path.slice(0);
subs.push(i);
Expand Down
33 changes: 19 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"url": "https://github.com/robtweed/ewd-document-store/issues"
},
"engines": {
"node": ">= 0.10",
"npm": ">= 2.15"
"node": ">= 4"
},
"repository": {
"type": "git",
Expand All @@ -25,10 +24,15 @@
"test": "npm run test:unit && npm run test:integration",
"test:unit": "jasmine --config=spec/support/unit.json",
"test:integration": "jasmine --config=spec/support/integration.json",
"test:integration:gtm": "DATABASE=gtm jasmine --config=spec/support/integration.json",
"test:integration:cache": "DATABASE=cache jasmine --config=spec/support/integration.json",
"test:integration:redis": "DATABASE=redis jasmine --config=spec/support/integration.json",
"coverage:unit": "nyc --reporter=html --reporter=text jasmine --config=spec/support/unit.json",
"coverage:integration": "nyc --reporter=html --reporter=text jasmine --config=spec/support/integration.json",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"validate": "npm ls"
"coverage:integration": "nyc --reporter=html --reporter=text npm run test:integration",
"coverage:integration:gtm": "nyc --reporter=html --reporter=text npm run test:integration:gtm",
"coverage:integration:cache": "nyc --reporter=html --reporter=text npm run test:integration:cache",
"coverage:integration:redis": "nyc --reporter=html --reporter=text npm run test:integration:redis",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
},
"pre-commit": [
"lint",
Expand All @@ -38,19 +42,20 @@
"all": true,
"include": [
"lib/**/*.js"
],
"exclude": [
"spec/**/*.js"
]
},
"devDependencies": {
"coveralls": "^2.13.1",
"dotenv": "^4.0.0",
"jasmine": "^2.8.0",
"coveralls": "^3.0.2",
"dotenv": "^6.1.0",
"ewd-memory-globals": "^1.0.3",
"ewd-redis-globals": "^0.5.0",
"jasmine": "^3.2.0",
"jasmine-spec-reporter": "^4.1.1",
"jshint": "^2.9.5",
"nyc": "^11.1.0",
"jasmine-spy-matchers": "^2.1.0",
"jshint": "^2.9.6",
"nyc": "^13.0.1",
"pre-commit": "^1.2.2",
"rewire": "^2.5.2"
"rewire": "^4.0.1",
"tcp-netx": "^1.0.7-a"
}
}
1 change: 1 addition & 0 deletions spec/helpers/matchers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require('jasmine-spy-matchers');
Loading