items
simpleCart.find( [ params ] )
arguments:
- params (optional): object of parameters for searching items or a single id. If it is not provided, this returns all items
You can get an item simply by sending an ID:
simpleCart.find( "SCI-11" ); // returns the item with id of SCI-11, if it is in the cart
You can search for items in the cart by matching one or more fields in the object, or by using inequality searches:
var bob = simpleCart.add({name: "bob" , price: 2 , color:'blue' , size: 6 }), joe = simpleCart.add({name: "joe" , price: 3 , color:'orange' , size: 3 }), jeff = simpleCart.add({name: "jeff" , price: 4 , color:'blue' , size: 4 }), bill = simpleCart.add({name: "bill" , price: 5 , color:'red' , size: 5 }); console.log( simpleCart.find({ color: 'orange' }) ); // [ joe ] console.log( simpleCart.find({ price: '>=4' }) ); // [ jeff , bill ] console.log( simpleCart.find({ size: '<5' }) ); // [ bob , joe , jeff ] console.log( simpleCart.find({ name: "bob" }) ); // [ bob ] console.log( simpleCart.find({ color: 'blue', size: '<4' }) ); // [ bob ]
Comments
- There are no comments for this entry yet.