Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

build-entities

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

build-entities

build content class entity with properties and hydrate methode

  • 1.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

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 !

Keywords

FAQs

Package last updated on 06 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc