forked from jaystack/jaydata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebsqlClient.html
38 lines (33 loc) · 1.14 KB
/
websqlClient.html
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
<!DOCTYPE HTML>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="build/jaydata.js"></script>
<script>
$(function() {
$data.Entity.extend("My.Entity", {
id: { type: "int", key: true, computed: true },
name: { type: "string" }
});
$data.EntityContext.extend("My.Context", {
Entities: { type: $data.EntitySet, elementType: My.Entity }
});
var c = new My.Context({name: "sqLite", databaseName: "new items"});
c.onReady( function() {
c.Entities.add(new My.Entity({name: Math.random()}));
c.saveChanges(function() {
$('#output').append($('<div>new item saved</div>'));
c.Entities.forEach( function(e) {
$('#output').append($('<div></div>').text('Id:' + e.id + ',name:' + e.name));
})
})
});
});
</script>
<title></title>
</head>
<body>
<div id="output">
</div>
</body>
</html>