node-json-db
Advanced tools
Comparing version
(function () { | ||
"use strict"; | ||
var arrayIndexRegex = /(.+)\[(\d+)\]/; | ||
var arrayIndexRegex = /(.+)\[(.+)\]/; | ||
var endsWith = function (str, suffix) { | ||
@@ -5,0 +5,0 @@ return str.indexOf(suffix, str.length - suffix.length) !== -1; |
{ | ||
"name": "node-json-db", | ||
"version": "0.4.5", | ||
"version": "0.4.6", | ||
"description": "Database using JSON file as storage for Node.JS", | ||
@@ -5,0 +5,0 @@ "main": "./JsonDB.js", |
@@ -116,2 +116,6 @@ [](http://travis-ci.org/Belphemur/node-json-db) [](https://coveralls.io/r/Belphemur/node-json-db?branch=master) | ||
//The index can be also non-numerical | ||
//This will create an array 'myarray' with the object '{obj:'test'}' with key test | ||
db.push("/arraytest/myarray[test]", {obj:'test'}, true); | ||
//You can retrieve a property of an object included in an array | ||
@@ -118,0 +122,0 @@ //testString = 'test'; |
@@ -177,2 +177,17 @@ var expect = require("expect.js"); | ||
}); | ||
it('should create an array with a string at index TEST', function () { | ||
db.push('/arraytest/myarray[TEST]', "works", true); | ||
var myarray = db.getData('/arraytest/myarray'); | ||
expect(myarray).to.be.an('array'); | ||
expect(myarray['TEST']).to.be('works'); | ||
}); | ||
it('should create an array with a string at index "TEST test"', function () { | ||
db.push('/arraytest/myarray[TEST test]', "workingTest", true); | ||
var myarray = db.getData('/arraytest/myarray'); | ||
expect(myarray).to.be.an('array'); | ||
expect(myarray['TEST test']).to.be('workingTest'); | ||
}); | ||
it('should add an object at index 1', function () { | ||
@@ -179,0 +194,0 @@ var obj = {property: "perfect"}; |
37613
2.33%693
1.76%171
2.4%