build content class entity with properties getters/setter auto check type , hydrate methode
installation
- npm install build-entities --save-dev
- yarn add build-entities
usage:
const buildEntities = require('build-entities') ;
const buildParams = {
name: "Product" ,
properties: [
{
name: "title" ,
type: "string"
} , {
name: "createAt" ,
type: "date"
} , {
relation: true,
name: 'user' ,
type: 'User'
}
] ,
} ;
buildEntities( buildParams )
.then( response => {
if( response.success ) {
const entityTextContent = response.data ;
const status = response.file( __dirname ) ;
if( status ) {
console.log('entity build success')
} else {
console.log( 'path create dir not exists' ) ;
}
} else {
}
} )
.catch( err => {
console.log( err ) ;
throw 'build entity error' ;
} ) ;
or synchrone call with:
const response = buildEntities.sync( buildParams ) ;
if( response.success ) {
} else {
}
you can generate doc block client with optional params client
:
const buildParams = {
name: "Product" ,
properties: [
{
name: "title" ,
type: "string"
} , {
name: "createAt" ,
type: "date"
} , {
relation: true,
name: 'user' ,
type: 'User'
}
] ,
client: {
author: "S.Author <super.author@hotmail.com>" ,
package: "build-entities-cli" ,
version: "0.1.0" ,
license: "BSD-2-CLAUSE"
}
} ;
types list :
- string
- number
- date
- boolean
- array
- object
or object name with relation: true
{
relation: true,
type: "ObjectName" ,
name: "objectName"
}
develop by Samuel Gaborieau with <3 and Nodejs for OpenSource , enjoy !