https://github.com/ihtml5/jscalpel-orm
It is convenient for you to extract the required fields from one object to generate another object.
https://github.com/ihtml5/jscalpel-orm
angular jscalpel object orm parser react vue
Last synced: 1 day ago
JSON representation
It is convenient for you to extract the required fields from one object to generate another object.
- Host: GitHub
- URL: https://github.com/ihtml5/jscalpel-orm
- Owner: ihtml5
- License: mit
- Created: 2018-03-08T23:07:23.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-26T15:24:52.000Z (almost 8 years ago)
- Last Synced: 2025-12-27T09:25:23.699Z (3 months ago)
- Topics: angular, jscalpel, object, orm, parser, react, vue
- Language: JavaScript
- Homepage: http://ihtml5.github.io/jscalpel-orm
- Size: 37.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jscalpel-orm
It is convenient for you to extract the required fields from one object to generate another object.
## dependency
[jscalpel](http://www.github.com/ihtml5/jscalpel)
## Installation
#### Install using npm
[](https://npmjs.org/package/jscalpel-orm)
```
npm install jscalpel-orm --save
yarn add jscalpel-orm --save
```
## Useage
#### Es6
```javascript
import JscalpelORM from 'jscalpel-orm'
```
#### Include in html
```javascript
```
## APIS
| parameter | type| default value | use| isRequired | required version |
|----------|:-------------:|------:|------:|------:|------:|
| source | object | empty object | source object | true | no |
| rules | object | empty object | map rules |true |no |
| _extraInfo | object | empty object | extra info |false |no |
## Demos
#### es6
import jscalpelORM from 'jscalpelORM';
const source = {
data: {
articles: [{
imgUrl: 'https://avatars0.githubusercontent.com/u/6822604?s=460&v=4',
title: ‘jscalpelORM'
}],
},
msg: 'ok',
code: 0,
}
const rules = {
imgUrl: 'data.articles.0.imgUrl',
msg: 'msg',
articles: 'data.articles',
title: 'data.articles.0.imgUrl',
};
const _extraInfo = {
name: 'jscalpelORM',
};
const newTarget = jscalpelORM(source, rules, _extraInfo);
// output
{
imgUrl: 'https://avatars0.githubusercontent.com/u/6822604?s=460&v=4',
title: ‘jscalpelORM',
articles: [{
imgUrl: 'https://avatars0.githubusercontent.com/u/6822604?s=460&v=4',
title: ‘jscalpelORM'
}],
msg: 'msg',
name: 'jscalpelORM',
}
#### es5
var source = {
data: {
articles: [{
imgUrl: 'https://avatars0.githubusercontent.com/u/6822604?s=460&v=4',
title: ‘jscalpelORM'
}],
},
msg: 'ok',
code: 0,
}
var rules = {
imgUrl: 'data.articles.0.imgUrl',
msg: 'msg',
articles: 'data.articles',
title: 'data.articles.0.imgUrl',
};
var _extraInfo = {
name: 'jscalpelORM',
};
var newTarget = jscalpelORM(source, rules, _extraInfo);
// output
{
imgUrl: 'https://avatars0.githubusercontent.com/u/6822604?s=460&v=4',
title: ‘jscalpelORM',
articles: [{
imgUrl: 'https://avatars0.githubusercontent.com/u/6822604?s=460&v=4',
title: ‘jscalpelORM'
}],
msg: 'msg',
name: 'jscalpelORM',
}