forked from chnak/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
37 lines (32 loc) · 1.13 KB
/
test.js
File metadata and controls
37 lines (32 loc) · 1.13 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
var $data = require("jaydata");
$data.Entity.extend("Todo", {
Id: { type: String, key: true, computed: true },
Task: { type: String, required: true, maxLength: 200 },
DueDate: { type: Date },
Completed: { type: Boolean },
Person: { type: "Person", required: true, inverseProperty: "Todos"}
});
$data.Entity.extend("Person", {
Id: { type: String, key: true, computed: true },
Name: { type: String, required: true, maxLength: 200 },
Todos: { type: Array, elementType: Todo, inverseProperty: "Person" }
});
$data.EntityContext.extend("TodoDatabase", {
Todos: { type: $data.EntitySet, elementType: Todo },
People: { type: $data.EntitySet, elementType: Person }
});
var todoDB = new TodoDatabase({
provider: 'mongoDB' , databaseName: 'MyTodoDatabase'
});
todoDB.onReady(function() {
//Work with todoDB now
console.log(1111111111);
var tasks = todoDB.Todos.addMany([
{ Task: 'Step0: Get this this list'},
{ Task: 'Step1: Define your data model'},
{ Task: 'Step2: Initialize data storage'}
]);
todoDB.saveChanges(function() {
tasks.forEach( function(todo) { console.log(todo.Id) });
});
});