-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapperchainexample.js
More file actions
101 lines (55 loc) · 1.92 KB
/
mapperchainexample.js
File metadata and controls
101 lines (55 loc) · 1.92 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
var _OBJY = require('./objy.js');
var OBJY = new _OBJY();
OBJY.Logger.enabled = ['none']
var s1 = [];
var s2 = [{secondo:'piano'}];
var cache = OBJY.customStorage({
createClient: function(client, success, error) { },
getDBByMultitenancy: function(client) { },
listClients: function(success, error) { },
getById: function(id, success, error, app, client) {
success(s2[0], 'return');
},
getByCriteria: function(criteria, success, error, app, client, flags) {
success(s2)
},
count: function(criteria, success, error, app, client, flags) { },
update: function(spooElement, success, error, app, client) { },
add: function(spooElement, success, error, app, client) {
console.log('getting from chain', spooElement)
s2.push(spooElement);
success(spooElement)
console.log(s1, s2)
},
remove: function(spooElement, success, error, app, client) { }
});
var db = OBJY.customStorage({
getById: function(id, success, error, app, client, chain) {
s1[0].getbyid = 1;
success(s1[0]);
},
getByCriteria: function(criteria, success, error, app, client, flags) {
success(s1)
},
count: function(criteria, success, error, app, client, flags) { },
update: function(spooElement, success, error, app, client) { },
add: function(spooElement, success, error, chain, app, client) {
spooElement.hello = 'sagasgd';
spooElement.getbyid = 1;
s1.push(spooElement);
success(spooElement)
},
remove: function(spooElement, success, error, app, client) { }
});
OBJY.define({
name: 'object',
pluralName: 'objects',
storage: [cache, db]
});
console.log(OBJY.mappers)
OBJY.object({name: 'grace'}).add(data => {
console.log('ID', data._id)
OBJY.objects({}).get(_d => {
console.log('GOT:', _d)
})
});