Comparing version 0.0.1 to 0.0.2
@@ -8,3 +8,3 @@ window.runExample = function(){ | ||
// create two example collections | ||
var users = db.addCollection('users','User', ['email']); | ||
var users = db.addCollection('users','User', ['email'], true); | ||
var projects = db.addCollection('projects', 'Project', ['name']); | ||
@@ -16,9 +16,9 @@ | ||
// create two users | ||
var odin = users.document( { name : 'odin', email: 'odin.soap@lokijs.com', age: 38 } ); | ||
var thor = users.document( { name : 'thor', email : 'thor.soap@lokijs.com', age: 25 } ); | ||
var stan = users.document( { name : 'stan', email : 'stan.soap@lokijs.com', age: 29 } ); | ||
var oliver = users.document( { name : 'oliver', email : 'oliver.soap@lokijs.com', age: 31 } ); | ||
var hector = users.document( { name : 'hector', email : 'hector.soap@lokijs.com', age: 15} ); | ||
var achilles = users.document( { name : 'achilles', email : 'achilles.soap@lokijs.com', age: 31 } ); | ||
// create six users | ||
var odin = users.document( { name : 'odin', email: 'odin.soap@lokijs.org', age: 38 } ); | ||
var thor = users.document( { name : 'thor', email : 'thor.soap@lokijs.org', age: 25 } ); | ||
var stan = users.document( { name : 'stan', email : 'stan.soap@lokijs.org', age: 29 } ); | ||
var oliver = users.document( { name : 'oliver', email : 'oliver.soap@lokijs.org', age: 31 } ); | ||
var hector = users.document( { name : 'hector', email : 'hector.soap@lokijs.org', age: 15} ); | ||
var achilles = users.document( { name : 'achilles', email : 'achilles.soap@lokijs.org', age: 31 } ); | ||
@@ -32,3 +32,3 @@ | ||
stan.name = 'Joe Minichino'; | ||
stan.name = 'Stan Laurel'; | ||
@@ -49,12 +49,14 @@ // update object (this really only syncs the index) | ||
// test the filters | ||
trace('View test'); | ||
trace('Example: View "Age" test'); | ||
trace(users.view(ageView)); | ||
trace('End view test'); | ||
sep(); | ||
trace('Custom filter'); | ||
trace('Example: Custom filter test'); | ||
trace(users.view(aCustomFilter)); | ||
trace('End of custom filter'); | ||
sep(); | ||
// example of map reduce | ||
trace('Map-reduce...'); | ||
trace('Example: Map-reduce'); | ||
function mapFun(obj){ | ||
@@ -64,15 +66,33 @@ return obj.age; | ||
function reduceFun(array){ | ||
var len = array.length >>> 0; | ||
var i = len; | ||
var cumulator = 0; | ||
while(i--){ | ||
cumulator += array[i]; | ||
} | ||
return cumulator / len; | ||
var len = array.length >>> 0; | ||
var i = len; | ||
var cumulator = 0; | ||
while(i--){ | ||
cumulator += array[i]; | ||
} | ||
return cumulator / len; | ||
} | ||
trace('Average age is : ' + users.mapReduce( mapFun, reduceFun).toFixed(2) ); | ||
trace('End of map-reduce'); | ||
sep(); | ||
trace('End of map-reduce...'); | ||
trace('Example: stringify'); | ||
trace('String representation : ' + db.serialize()); | ||
trace('End stringify example'); | ||
sep(); | ||
trace('Example: findAndModify'); | ||
function updateAge(obj){ | ||
obj.age *= 2; | ||
return obj; | ||
} | ||
users.findAndModify(ageView, updateAge); | ||
trace(users.find()); | ||
trace('End findAndModify example'); | ||
function sep(){ | ||
trace('//---------------------------------------------//'); | ||
} | ||
} catch(err){ | ||
@@ -79,0 +99,0 @@ console.log(err); |
{ | ||
"name": "lokijs", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A document oriented javascript client side database", | ||
"main": "src/LokiJS.js", | ||
"main": "src/lokijs.js", | ||
"directories": { | ||
@@ -7,0 +7,0 @@ "example": "examples" |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
247723
12
6983
3
2