minorm
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "minorm", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "MinORM - minimal MySQL ORM with performance as the Goal", | ||
@@ -9,3 +9,3 @@ "main": "lib/index.js", | ||
"prepublish": "npm run dist", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "nyc --reporter=lcov --require babel-register ./node_modules/.bin/_mocha" | ||
}, | ||
@@ -31,2 +31,3 @@ "repository": { | ||
"babel-eslint": "^7.0.0", | ||
"babel-plugin-istanbul": "^2.0.1", | ||
"babel-preset-nodejs6": "^1.0.0", | ||
@@ -39,4 +40,4 @@ "babel-preset-react": "^6.16.0", | ||
"eslint-plugin-flowtype": "^2.19.0", | ||
"isparta": "^4.0.0", | ||
"mocha": "^3.1.0" | ||
"mocha": "^3.1.0", | ||
"nyc": "^8.3.0" | ||
}, | ||
@@ -46,3 +47,6 @@ "dependencies": { | ||
"squel": "^5.4.3" | ||
}, | ||
"engines": { | ||
"node": ">=6.0" | ||
} | ||
} |
# MinORM | ||
[![Build Status](https://travis-ci.org/Arilas/minorm.svg?branch=master)](https://travis-ci.org/Arilas/minorm) | ||
[![codecov](https://codecov.io/gh/Arilas/minorm/branch/master/graph/badge.svg)](https://codecov.io/gh/Arilas/minorm) | ||
MinORM is a high-performance ORM built on top of [Node MySQL2](https://github.com/sidorares/node-mysql2) | ||
that is a continuation of Node MySQL-Native. Also MinORM uses Squel library as Query Builder | ||
that is a continuation of Node MySQL-Native. Also MinORM uses [Squel](https://github.com/hiddentao/squel) library as Query Builder | ||
@@ -10,3 +13,3 @@ It's really lightweight, provide simple solutions that just works without a lot of configurations. | ||
If you are tired by highweight ORMs like Bookshelf or Sequelize, and want just some basic functionality | ||
If you are tired by highweight ORMs like [Bookshelf](https://github.com/tgriesser/bookshelf) or [Sequelize](https://github.com/sequelize/sequelize), and want just some basic functionality | ||
from it - MinORM can be a good start point. | ||
@@ -13,0 +16,0 @@ |
@@ -7,3 +7,3 @@ /** @flow */ | ||
export function createManager(connectionConfig: any, logger?: typeof console = false): Manager { | ||
export function createManager(connectionConfig: any, logger?: ?typeof console = null): Manager { | ||
const pool = MySQL.createPool(connectionConfig) | ||
@@ -15,3 +15,3 @@ /** | ||
*/ | ||
const repos = {} | ||
let repos = {} | ||
/** | ||
@@ -28,3 +28,3 @@ * { | ||
*/ | ||
const associations: {[key: string]: {[key: string]: Relation}} = {} | ||
let associations: {[key: string]: {[key: string]: Relation}} = {} | ||
@@ -42,2 +42,9 @@ return { | ||
}, | ||
getPool() { | ||
return pool | ||
}, | ||
clear() { | ||
repos = {} | ||
associations = {} | ||
}, | ||
getConnection() { | ||
@@ -52,2 +59,3 @@ return pool.getConnection() | ||
} | ||
// $FlowIgnore impossible situation | ||
logger && logger.debug(`SQL query: ${sql}`) | ||
@@ -54,0 +62,0 @@ return pool.query(sql, values) |
@@ -51,3 +51,3 @@ /** @flow */ | ||
export function createRepository(tableName: string, manager: Manager): Repository { | ||
loadRelations(manager, tableName) | ||
manager.hasOwnProperty('_setRelationFrom') && loadRelations(manager, tableName) | ||
const repo = { | ||
@@ -54,0 +54,0 @@ find(id: any) { |
@@ -11,3 +11,3 @@ /** @flow */ | ||
export type Criteria = { | ||
[key: string]: string | { | ||
[key: string]: string | number | { | ||
[key: string]: any | ||
@@ -20,6 +20,6 @@ } | ||
findOneBy(criteria: Criteria): Promise<?Model>, | ||
findBy(criteria: Criteria, orderBy: {[key: string]: string}, limit?: number, offset?: number): Promise<Array<Model>>, | ||
findBy(criteria: Criteria, orderBy?: {[key: string]: string}, limit?: number, offset?: number): Promise<Array<Model>>, | ||
create(data: {[key: string]: any}): Model, | ||
hydrate(data: {[key: string]: any}, isFetched?: boolean): Model, | ||
_save(changes: {[key: string]: any}, id?: number): Promise<number|string> | ||
_save(changes: {[key: string]: any}, id?: number): Promise<number|string|null> | ||
} | ||
@@ -26,0 +26,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
39284
25
818
1
80
12