model-convert
v1.0.1
Published
helps you convert your non-unified models from various sources into a single model you can use
Downloads
3
Maintainers
Readme
model-convert
Convert models from different schemas into a unified model you can actually use
#Install
npm install model-convert --save
#Usage
var ConverterFactory = require('model-convert');
var rules = {
v1 : {
'userObject.userName' : 'name'
},
v2 : {
'userObject.user_name' : 'name'
}
};
var converter = new ConverterFactory(rules);
For:
converter({ userObject : { userName : 'dan' } })
Result:
{ name : 'dan' });
For:
converter({ user_object : { user_name : 'dan' } } )
Result:
{ name : 'dan' });
#Things to be aware of!
vNull is the version name if no proper version is found As Per model-detect
deep-value can search arrays deep-value
deep-setter can set arrays *syntax varies from deep-value deep-setter