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

@nyffels/mynodeorm

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nyffels/mynodeorm

A full-fledged ORM framework for NodeJS and MySQL with develop friendly code aimed to handle database migrations, MySQL Query builder / helper and property mapping.

  • 1.0.0-alpha65
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
105
decreased by-83.82%
Maintainers
0
Weekly downloads
 
Created
Source

MyNodeORM

A full-fledged ORM framework for NodeJS and MySQL with develop friendly code aimed to handle database migrations, MySQL Query builder / helper and property mapping.

Installation

Use the npm package manager to install "MySQL Query Builder" by running the command

npm install @nyffels/mynodeorm

Usage

Map a class to a MySQL table

You need to map your class to a MySQL table and columns to use them in the QueryBuilder function. A mapping happens partial on class level and partial on property level. \

Class decorators

The @id decorator will allow the developer to fetch the class by it's id.
Key: string: This parameter is the ID used to link the string to a class
Class: object: this Object is the class itself declared under this decorator
@id(Key, Class)

The @table decorator contains the name of the table that is linked to this class.
mySqlTableName: string: This includes the MySQL table name linked to this class and will be used in the QueryBuilder
@table(mySqlTableName)

Property decorators

The @column decorator contains the name of the column that is linked to this property.
mySqlColumnName: string: This includes the MySQL column name linked to this property and will be used in the QueryBuidler
@column(mySqlColumnName)

The @type decorator contains the type of the column. If @type is missing of invalid the type will default to a string.
propertyType: number | boolean | date | datetime | string: The decorator contains information about the column type. For all the non-string values it is best practice to declare the types to be 100% certain on SQL generation. @type(propertyType)

Example:


@id("exWork", WorkClass)\
@table("Ex_work")\
export class WorkClass {
   @column("workStart")
   @type("datetime")
   start: Date;

   @column("workEnd")
   @type("datetime")
   end: Date;

   constructor() {}
}

Query Builder

TODO documentation

Standalone functions

MySQL Connections

setConnection()
TODO documentation

getConnection(skipNoConnectionError = true)
TODO documentation

endConnection()
TODO documentation

Query handling

doMutation(sqlQuery: string, options: QueryOptions | null = null)
TODO documentation

doQuery<T = any>(sqlQuery: string, options: QueryOptions | null = null)
TODO documentation

queryResultToObject<T = any>(classObject: Object, results: any[])
TODO documentation

Value parsers

parseString(value: string)
TODO documentation

parseNumber(value: number)
TODO documentation

parseBoolean(value: boolean, canBeNull = false)
TODO documentation

parseDate(date: Date, time = false)
TODO documentation

parseValue(sourceClass: any, property: string, value: any)
TODO documentation

Database Migration

Currently not available in the framework. This function will be released in a newer version.

Progress

  • Property mapping
  • Query helpers
  • Query builders
  • Database migration tool

Contributing

Pull requests are welcome but open an issue first to discuss what you would like to change.
For major changes, please open an issue first to discuss what you would like to change.

License

MIT - Copyright (c) 2023-2024 Nyffels BV

github (https://github.com/Nyffels-Open-Source/mysql-query-builder)
npmjs (https://www.npmjs.com/package/@nyffels/mysql-query-builder)

Dependencies

Release notes

Currently in Alpha development with possible breaking changes. Use this software at your own risk. Nyffels doesn't provide Release notes or changelogs at this stage of development.

Keywords

FAQs

Package last updated on 01 Dec 2024

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