https://github.com/molda/clientschemas
https://github.com/molda/clientschemas
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/molda/clientschemas
- Owner: molda
- Created: 2016-12-17T20:05:51.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-22T19:43:15.000Z (over 9 years ago)
- Last Synced: 2025-03-29T10:48:10.866Z (about 1 year ago)
- Language: JavaScript
- Size: 221 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Client-side schemas for Total.js
## **BETA VERSION - use at your own risk**
### How it works
All you need is the clientschemas.js module.
Then initialize the module, by using bellow code in some definition file
```javascript
F.on('module#clientschemas', function(module) {
module.init({
schemas: {
'Contact': { // this will allow access to Contact schema
authorize: true,// same as authorize flag in route definition, uses F.onAuthorize
role: '@admin' // same as @role flag in route definition
}
}
});
});
```
### Now it's time to use it on the client
First add a script:
```html
```
Now you can use it. `SCHEMA` is a global variable
```javascript
SCHEMA('Contact').save({"email":"smolamartin@seznam.dsf"}, function(err, response){
console.log('SAVE', err, response);
}).workflow('some-workflow').exec();
SCHEMA('Contact').get({id: }, function(err, response){
console.log('GET', err, response);
}).exec();
SCHEMA('Contact').query(function(err, response){
console.log('QUERY', err, response);
}).exec();
```