
var ostore = require('..');

exports['add and remove an item'] = function (test) {
    var store = ostore.createStore();
    var item = { name: 'Adam', age: 800 };
    
    var result = store.add(item);
    
    test.ok(result);
    test.equal(result, 1);
    test.equal(item.id, null);
    
    var newitem = store.get(result);
    
    test.ok(newitem);
    test.equal(newitem.id, result);
    test.equal(newitem.name, item.name);
    test.equal(newitem.age, item.age);
    
    store.remove(result);
    
    test.equal(store.get(result), null);
};

exports['remove item using criteria'] = function (test) {
    var store = ostore.createStore();
    var adam = { name: 'Adam', age: 800 };
    var eve = { name: 'Eve', age: 700 };
    
    store.add(adam);
    store.add(eve);
    
    store.remove({ name: 'Adam' });
    
    var result = store.find();
    
    test.ok(result);
    test.equal(result.length, 1);
    test.equal(result[0].name, 'Eve');
    test.equal(result[0].age, 700);
};

@@ -1022,16 +1022,418 @@
 age, 700);%0D%0A%7D;%0D%0A
+%0D%0Aexports%5B'remove item using criteria with operator'%5D = function (test) %7B%0D%0A    var store = ostore.createStore();%0D%0A    var adam = %7B name: 'Adam', age: 800 %7D;%0D%0A    var eve = %7B name: 'Eve', age: 700 %7D;%0D%0A    %0D%0A    store.add(adam);%0D%0A    store.add(eve);%0D%0A    %0D%0A    store.remove(%7B age: %7B $gt: 100 %7D %7D);%0D%0A    %0D%0A    var result = store.find();%0D%0A    %0D%0A    test.ok(result);%0D%0A    test.equal(result.length, 0);%0D%0A%7D;%0D%0A

Remove items using criteria with operator