npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

entity-baker

v0.21.5

Published

Generates simple and powerful entity classes for ORM systems, like Doctrine and/or Entity Framework.

Downloads

7

Readme

npm npm

node-entity-baker

Node.js application / library, which generates simple and powerful entity classes for ORM systems, like Doctrine and/or Entity Framework, wriiten in TypeScript.

Installation

As command line tool:

npm install -g entity-baker

As module:

npm install --save entity-baker

Usage

First create a entities.json file inside your working directory (can also be in XML or YAML format, s. examples folder):

{
    "namespace": "MarcelJoachimKloubert.Database",

    "entities": {
        "Log": {
            "table": "logs",

            "columns": {
                "id": {
                    "id": true,
                    "auto": true,
                    "type": "int32"
                },
                
                "level": {
                    "null": true,
                    "type": "int16"
                },
                
                "message": "string",
                "tag": {
                    "null": true,
                    "type": "string"
                },
                
                "context": {
                    "null": true,
                    "type": "json"
                }
            }
        }
    }
}

From command line

# run it from your working directory
entity-baker --doctrine --entity-framework --entity-framework-core

As module

JavaScript

var EntityBaker = require('entity-baker');

TypeScript

import * as EntityBaker from 'entity-baker';

compile

var fs = require('fs');

var entityFile = JSON.parse(
    fs.readFileSync('./entities.json', 'utf8')
);

EntityBaker.compile({
    cwd: '/path/to/working/directory',
    file: entityFile,
    outDir: '/path/to/output/directory',
       target: 1,  // Doctrine
    // target: 2  // Entity Framework
    // target: 3  // Entity Framework Core

    callbacks: {
        onBeforeGenerateClass: function(className, target) {
        },

        onClassGenerated: function(err, className, target) {
        }
    }
}).then(function() {
    // files generated
}, function (err) {
    // error while generating files
});

Data types

Type | Doctrine | Entity Framework ------------ | ------------- | ------------- bigint | bigint | System.Int64 | bin | binary | System.Byte[] | binary | binary | System.Byte[] | blob | blob | System.Byte[] | bool | boolean | System.Boolean | boolean | boolean | System.Boolean | date | date | System.Int64 | datetime | datetime | System.Int64 | datetimetz | datetimetz | System.DateTimeOffset | decimal | decimal | System.Decimal | float | float | System.Single | guid | guid | System.Guid | int | integer | System.Int32 | int16 | smallint | System.Int16 | int32 | integer | System.Int32 | int64 | bigint | System.Int64 | integer | integer | System.Int32 | json | json | dynamic | smallint | smallint | System.Int16 | str | string | System.String | string | string | System.String | text | text | System.String | time | time | System.TimeSpan | uint16 | smallint | System.UInt16 | uint32 | integer | System.UInt32 | uint64 | bigint | System.UInt64 | uuid | guid | System.Guid |

If you do not define a data type, it set to

  • int32, if the column is a primary key, or...
  • string, if nothing else matches

Support and contribute []

If you like the module, you can support the project by sending a donation via PayPal to me.

To contribute, you can open an issue and/or fork this repository.

To work with the code:

  • clone this repository
  • create and change to a new branch, like git checkout -b my_new_feature
  • run npm install from your project folder
  • edit and debug in your favorite editor, like Visual Studio Code
  • commit your changes to your new branch and sync it with your forked GitHub repo
  • make a pull request

The API documentation can be found here.