-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.html
More file actions
88 lines (76 loc) · 2.14 KB
/
example.html
File metadata and controls
88 lines (76 loc) · 2.14 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
<html>
<head>
<script src="dist/browser.js"></script>
<script src="dist/mappers/storage.local.js"></script>
<script>
//console.log(OBJY)
var mapper = new LocalMapper(OBJY);
mapper.createClient('default', () => {})
OBJY.client('local');
OBJY.activeApp = "testapp"
OBJY.staticRules.push({
_id: 123,
affects: {},
apply: {
onCreate: {
perms: {
trigger: 'after',
value: `
OBJY.objects({}).get(data => {
data.forEach(d => {
Object.keys(obj.permissions || {}).forEach(p => {
if(!d.permissions[p] || d.permissions[p].value != obj.permissions[p].value) d.setPermission(p, obj.permissions[p]).update()
})
})
})
`
}
}
}
})
OBJY.define({
name: "object",
pluralName: "objects",
storage: new LocalMapper(OBJY).useConnection(mapper.getConnection())
})
OBJY.define({
name: "user",
authable: true,
pluralName: "users",
storage: new LocalMapper(OBJY).useConnection(mapper.getConnection())
})
OBJY.object({ name: "otest", inherits: ["5f087f3e12f29a0012b346be"] }).add(obj => {
console.log('obj', obj);
}, (err) => {
console.log(err)
});
OBJY.user({
name: "utest",
permissions: {
admin: {
value: "*"
}
},
privileges: {
testapp: [
{ name: "admin" }
]
}
}).add(obj => {
console.log('obj', obj);
var obj = OBJY.user(obj);
obj.removePrivilege("admin")
console.log('after', obj);
}, (err) => {
console.log(err)
});
OBJY.objects({ "inherits": { "$in": ["5f087f3e12f29a0012b346be"] } }).get(function(data) {
console.log('got data:', data)
}, function(err) {
console.log('err:', err)
})
</script>
</head>
<body>
</body>
</html>