Labs/Jetpack/JEP/22: Difference between revisions

Line 34: Line 34:
}
}


jetpack.places.fetch("Groucho Marx", callback);


// ^^ you can pass in a string or an object...
jetpack.places.find({phrase: "Groucho Marx",
                    where: "history"}, callback);


jetpack.places.fetch({phrase: "Groucho Marx",
jetpack.places.find({phrase: "Groucho Marx",  
                    where: "history",
                     where:"bookmarks"}, callback)
                    since: "2009-03-01 12:00:01"}, callback);
 
jetpack.places.fetch({phrase: "Groucho Marx",
                    where:"everywhere",
                    before: "2008-12-31 00:00:01"}, callback)
 
jetpack.places.fetch({phrase: "Groucho Marx",  
                     where:"bookmarks",
                    between: ["2009-03-01 12:00:01", "2009-04-01 12:00:03"]},
                    callback)


// Write to the database
// Write to the database
Line 60: Line 50:
function callback(results) {
function callback(results) {


   dump(results.count); // 3
   dump(results.length); // 3


   for (let item in results) {
   for (let item in results) {
Line 67: Line 57:
     // result item (bookmark or history object)
     // result item (bookmark or history object)
   }
   }
  results[2].remove();


   results[1].title = "Groucho, we hardly knew ye!";
   results[1].title = "Groucho, we hardly knew ye!";
  results[1].tag("myhero"); // auto saves tags


   results[1].tags; // property returns ["myhero", "mustachioed-funny-guys",]
   results[1].tags; // property returns ["myhero", "mustachioed-funny-guys",]
  results[1].save(); // called to make all changes permanent
  results[3].tags = ['bar', 'baz', 'biff'] // setter


}
}


jetpack.places.fetch({ where:bookmarks,  
jetpack.places.find({ where: "bookmarks", phrase: "mustache"}, callback);
                        tags: ["marx-brothers"] }, callback);
</pre>
</pre>


564

edits