Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wizyma/object-transformer
Create models of data from object
https://github.com/wizyma/object-transformer
Last synced: about 2 months ago
JSON representation
Create models of data from object
- Host: GitHub
- URL: https://github.com/wizyma/object-transformer
- Owner: Wizyma
- License: mit
- Created: 2019-05-25T15:55:46.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T22:38:50.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T13:48:17.860Z (8 months ago)
- Language: JavaScript
- Size: 783 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OBJECT-TRANSFORMER-MODEL
## WIP - WORK IN PROGRESS
Basicly my need where => I have x field with some of them wich are multi select,
once every field is filled i need to create dynamicly an array of models for the server to
match the api schema.
I built this in mind of not taking in account the keys of my specific need so it can be used
with anything.## try it
```bash=
# npm
$ npm install object-transformer-model# yarn
$ yarn add object-transformer-model
```## Example
This is some kinda of case i ran into, each `hobbies` should be a single element in the database... !```javascript=
const getModels = require('object-transformer-model');const selectFromForm = {
name: 'André Gomes',
age: '25',
hobbies: ["Gaming", "Reading", "Programming", "Music"],
}const models = getModels(selectFromForm);
/*
RESULT :
[
{
hobbies: 'Gaming',
name: 'André Gomes',
age: '25'
},
{
hobbies: 'Reading',
name: 'André Gomes',
age: '25'
},
{
hobbies: 'Programming',
name: 'André Gomes',
age: '25'
},
{
hobbies: 'Music',
name: 'André Gomes',
age: '25'
}
]
*/
```# Contribution
PR's and feedback are welcome !