Skip to content

Instantly share code, notes, and snippets.

@k33g
Created June 3, 2012 07:31
Show Gist options
  • Save k33g/2862464 to your computer and use it in GitHub Desktop.
Save k33g/2862464 to your computer and use it in GitHub Desktop.
//save
cyste.storage("TERRA12")
.kind("human") //optional
.key(cyste.guid()) //unique key
.criteria({name:"bob", age : Math.floor(Math.random()*100)+15 }) //secondary keys
.setItem(
{ name : "Bob", adress : { street : "4 av Berthelot", town : "Lyon"}},
function(){ console.log("Bob saved ..."); }
);
cyste.storage("TERRA12")
.kind("dog")
.key(cyste.guid())
.criteria({name:"Wolf", age : Math.floor(Math.random()*8)})
.setItem(
{name : "Wolf", specy : "Chiwawa", age : 2},
function(){ console.log("Wolf saved ..."); }
);
var Angelina = {
firstName : "Angelina",
lastName : "Jolie",
details : {
movie : "LaraCroft",
father : "Jon Voight"
}
};
//new Date(année, mois, jour)
cyste.storage("TERRA12")
.kind("woman")
//.key("YYYY") /* unique key is optional */
.criteria({ WHEN : (new Date(2012,7,5)), val : Math.random() })
.setItem(Angelina, function(){ console.log("Angelina saved ..."); });
//query
cyste.storage("TERRA7").kind("woman").find({name : "when", between :{ min:new Date('May 08, 2012'), max:new Date('May 15, 2012') }},function(recs) { console.log(recs); })
cyste.storage("TERRA7").kind("woman").find({name:"when",value : new Date('May 08, 2012')},function(recs) { console.log(recs); })
cyste.storage("TERRA7").kind("woman").find({name : "when", between :{ min:new Date('May 08, 2012'), max:new Date('May 21, 2012') }},function(recs) { console.log(recs); })
cyste.storage("TERRA7")
.kind("dog")
.find(
{name : "age", between :{ min:4, max:5 }}
,function(recs) {
recs.forEach(function(rec){
console.log(rec.value, rec.name);
});
})
cyste.storage("TERRA7").kind("woman").find({name : "WHEN", value : new Date(2012,7,5), condition:"<"},function(recs) { recs.forEach(function(rec){console.log(rec.value, rec.name);}); })
cyste.storage("TERRA7").kind("woman")
.find({name : "WHEN", between :{ min:new Date(2012,5,5), max:new Date(2012,7,5) }},function(recs) { console.log(recs); })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment