public
Description: A relational database using <table> tags and jQuery
Homepage:
Clone URL: git://github.com/nkallen/jquery-database.git
jquery-database / example.html
100644 66 lines (65 sloc) 1.711 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<html>
  <head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
    <script type="text/javascript" src="jquery.db.js"></script>
    <script type="text/javascript">
      $(function() {
        console.debug(
          $('.users')
            .where('.id:eq(1)')
            .select('.name')
        );
        console.debug(
          $('.users')
            .where('.name:contains(a)')
              .and('.name:contains(c)')
            .select('*')
        );
        console.debug(
          $('.users')
            .join('.photos')
            .where('.photos.user_id:eq(.users.id)')
              .and('.users.id:eq(1)')
            .select('.photos.url')
                    );
      });
    </script>
  </head>
  <body>
    <table class="users">
      <tbody>
        <tr>
          <td class="id">1</td>
          <td class="name">amy</td>
        </tr>
        <tr>
          <td class="id">2</td>
          <td class="name">bob</td>
        </tr>
        <tr>
          <td class="id">3</td>
          <td class="name">carl</td>
        </tr>
      </tbody>
    </table>
    <table class="photos">
      <tbody>
        <tr>
          <td class="id">1</td>
          <td class="user_id">1</td>
          <td class="url">http://www.example.com/foo.png</td>
        </tr>
        <tr>
          <td class="id">2</td>
          <td class="user_id">2</td>
          <td class="url">http://www.example.com/bar.png</td>
        </tr>
        <tr>
          <td class="id">3</td>
          <td class="user_id">3</td>
          <td class="url">http://www.example.com/baz.png</td>
        </tr>
      </tbody>
    </table>
  </body>
</html>