Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 81 lines (57 sloc) 3.27 kb
aece7a4 Added back Readme
Ian authored
1 # TaffyDB (taffy.js)
2
3 TaffyDB is an opensouce library that brings database features into your JavaScript applications.
4
5 ## Introduction
6
7 How you ever noticed how JavaScript object literals look a lot like records? And that if you wrap a group of them up in an array you have something that atcs a lot like a database table? TaffyDB brings powerful database funtionality to that concept and rapidly improves the way you work with data inside of JavaScript.
8
9 ## What makes it sticky
10
11 - Extremely fast
12 - Powerful JavaScript centric data selection engine
13 - Database inspired features such as insert, update, unique, count, etc
14 - Robust cross browser support
15 - Easily extended with your own functions
16 - Compatible with any DOM library (jQuery, YUI, Dojo, etc)
17
18 ## Create a DB
19
20 Just pass in JSON:
21
22 var products = TAFFY([{
23 "item":1,
24 "name":"Blue Ray Player",
25 "price":99.99
26 }, {
27 "item":2,
28 name:"3D TV",
29 price:1799.99
30 }]);
31
32
33 ## Find data
34
35 Use JSON to compare:
36
37 var item1 = products({item:1});
38 // where item is equal to 1
39 var lowPricedItems = products({price:{lt:100}});
40 // where price is less than 100
41 var blueRayPlayers = products({name:{like:"Blue Ray"}});
42 // where name is like "Blue Ray"
43
44 ## Use data
45
46 // update the price of the Blue Ray Player to 89.99
47 products({item:1}).update({price:89.99});
48 // loop over the records and call a function
49 products().each(function (r) {alert(r.name)});
50 // get first record
51 products().first();
52 // get last record
53 products().last();
54 // sort the records by price descending
55 products.sort("price desc");
56 // select only the item names into an array
57 products().select("name"); // returns ["3D TV","Blue Ray Player"]
58 // inject values from a record into a string template
59 var row = products({item:2}).supplant("<tr><td>{name}</td><td>{price}</td></tr>");
60 // row now equal to "<tr><td>3D TV</td><td>17999.99</td></tr>"
61
62 ## Documentation, support, updates
63
64 View more docs and examples, get support, and get notified of updates:
65
66 Web: http://taffydb.com
62c5b9d @typicaljoe Fixed Twitter URL
authored
67 Twitter: http://twitter.com/biastoact
aece7a4 Added back Readme
Ian authored
68
69
70 ## Software License Agreement (BSD License)
71 Copyright (c)
72 All rights reserved.
73
74
75 Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following condition is met:
76
77 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
78
79 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
80 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Something went wrong with that request. Please try again.