build-entities

1.0.2 • Public • Published

build-entities

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 ;
 
        // generate file default name : {entityName}.js
        const status = response.file( __dirname /* [, nameFile] */ ) ;
 
        if( status ) {
 
            console.log('entity build success')
        } else {
 
            console.log( 'path create dir not exists' ) ;
        }
 
    } else {
 
        // error params
    }
} )
.catch( err => {
 
    // internal error
    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'
        }
    ] ,
 
    // for generate doc block optional params
    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 !

Package Sidebar

Install

npm i build-entities

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

63.5 kB

Total Files

26

Last publish

Collaborators

  • orivoir21