@nyffels/mynodeorm
Advanced tools
Comparing version 1.0.0-alpha63 to 1.0.0-alpha64
@@ -11,2 +11,36 @@ import 'reflect-metadata'; | ||
}; | ||
export declare function primary(): { | ||
(target: Function): void; | ||
(target: Object, propertyKey: string | symbol): void; | ||
}; | ||
export declare function nullable(isNullable: boolean): { | ||
(target: Function): void; | ||
(target: Object, propertyKey: string | symbol): void; | ||
}; | ||
export declare function unique(): { | ||
(target: Function): void; | ||
(target: Object, propertyKey: string | symbol): void; | ||
}; | ||
export declare function unsigned(): { | ||
(target: Function): void; | ||
(target: Object, propertyKey: string | symbol): void; | ||
}; | ||
export declare function autoIncrement(): { | ||
(target: Function): void; | ||
(target: Object, propertyKey: string | symbol): void; | ||
}; | ||
export declare function defaultSql(sql: string): { | ||
(target: Function): void; | ||
(target: Object, propertyKey: string | symbol): void; | ||
}; | ||
export declare function foreignKey<T>(table: T, column: keyof T, onDelete: ForeignKeyOption.Restrict, onUpdate?: ForeignKeyOption): { | ||
(target: Function): void; | ||
(target: Object, propertyKey: string | symbol): void; | ||
}; | ||
export declare enum ForeignKeyOption { | ||
Restrict = 0, | ||
Cascade = 1, | ||
SetNull = 2, | ||
NoAction = 3 | ||
} | ||
/** | ||
@@ -13,0 +47,0 @@ * Get a sql column from a property. If no column decorator found, it will return the propertykey. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ForeignKeyOption = void 0; | ||
exports.column = column; | ||
exports.type = type; | ||
exports.primary = primary; | ||
exports.nullable = nullable; | ||
exports.unique = unique; | ||
exports.unsigned = unsigned; | ||
exports.autoIncrement = autoIncrement; | ||
exports.defaultSql = defaultSql; | ||
exports.foreignKey = foreignKey; | ||
exports.getColumn = getColumn; | ||
@@ -12,2 +20,10 @@ exports.getAllProperties = getAllProperties; | ||
const typeMetaDatakey = Symbol('type'); | ||
const primaryMetaDatakey = Symbol('primary'); | ||
const nullableMetaDatakey = Symbol('nullable'); | ||
const uniqueMetaDatakey = Symbol('unique'); | ||
const indexMetaDatakey = Symbol('index'); | ||
const unsignedMetaDatakey = Symbol('unsigned'); | ||
const autoIncrementMetaDatakey = Symbol('autoIncrement'); | ||
const defaultMetaDatakey = Symbol('default'); | ||
const foreignKeyMetaDatakey = Symbol('foreignKey'); | ||
function column(databaseColumnName) { | ||
@@ -19,2 +35,30 @@ return Reflect.metadata(nameMetaDatakey, databaseColumnName); | ||
} | ||
function primary() { | ||
return Reflect.metadata(primaryMetaDatakey, true); | ||
} | ||
function nullable(isNullable) { | ||
return Reflect.metadata(nullableMetaDatakey, isNullable); | ||
} | ||
function unique() { | ||
return Reflect.metadata(uniqueMetaDatakey, true); | ||
} | ||
function unsigned() { | ||
return Reflect.metadata(unsignedMetaDatakey, true); | ||
} | ||
function autoIncrement() { | ||
return Reflect.metadata(autoIncrementMetaDatakey, true); | ||
} | ||
function defaultSql(sql) { | ||
return Reflect.metadata(defaultMetaDatakey, sql); | ||
} | ||
function foreignKey(table, column, onDelete, onUpdate = ForeignKeyOption.Restrict) { | ||
return Reflect.metadata(foreignKeyMetaDatakey, JSON.stringify({ table, column, onDelete, onUpdate })); | ||
} | ||
var ForeignKeyOption; | ||
(function (ForeignKeyOption) { | ||
ForeignKeyOption[ForeignKeyOption["Restrict"] = 0] = "Restrict"; | ||
ForeignKeyOption[ForeignKeyOption["Cascade"] = 1] = "Cascade"; | ||
ForeignKeyOption[ForeignKeyOption["SetNull"] = 2] = "SetNull"; | ||
ForeignKeyOption[ForeignKeyOption["NoAction"] = 3] = "NoAction"; | ||
})(ForeignKeyOption || (exports.ForeignKeyOption = ForeignKeyOption = {})); | ||
/** | ||
@@ -21,0 +65,0 @@ * Get a sql column from a property. If no column decorator found, it will return the propertykey. |
{ | ||
"name": "@nyffels/mynodeorm", | ||
"version": "1.0.0-alpha63", | ||
"version": "1.0.0-alpha64", | ||
"description": "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.", | ||
"private": false, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"main": "dist/index.js", | ||
@@ -42,3 +45,6 @@ "types": "dist/index.d.ts", | ||
"reflect-metadata": "^0.2.2" | ||
}, | ||
"bin": { | ||
"@nyffels/mynodeorm": "dist/app.js" | ||
} | ||
} |
@@ -18,4 +18,4 @@ { | ||
}, | ||
"include": ["src/index.ts"], | ||
"include": ["src/index.ts", "src/app.ts"], | ||
"lib": ["es6"], | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
111520
59
1566
6