Gathering detailed insights and metrics for tiny-entity2
Gathering detailed insights and metrics for tiny-entity2
Gathering detailed insights and metrics for tiny-entity2
Gathering detailed insights and metrics for tiny-entity2
npm install tiny-entity2
Typescript
Module System
Node Version
NPM Version
TypeScript (50.33%)
JavaScript (49.67%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
1 Stars
160 Commits
1 Watchers
8 Branches
1 Contributors
Updated on Sep 10, 2024
Latest Version
1.5.8
Package Id
tiny-entity2@1.5.8
Unpacked Size
230.57 kB
Size
37.72 kB
File Count
62
NPM Version
8.5.5
Node Version
16.15.0
Published on
May 16, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1$ npm install tiny-entity2
This is a ORM framework support Mysql and Sqlite3.
you can define an entity model like this:
1@Define.Table({ TableName: "person" }) 2export class Person extends EntityObjectMysql<Person> { 3 @Define.PrimaryKey() 4 id: string; 5 6 @Define.Column({ 7 DataType: Define.DataType.Decimal, 8 DataLength: 11, 9 DecimalPoint: 3 10 }) 11 weight: number; 12 13 @Define.Column() 14 name: string; 15 16 @Define.Column({ 17 DataType: Define.DataType.INT, 18 DataLength: 11 19 }) 20 age: number; 21 22 @Define.Column({ DataType: Define.DataType.BIGINT }) 23 birth: number; 24}
you can use PrimaryKey() define a primarykey for an entity , and also use Column() define a field. you can use some parameters for Column() like this:
1@Define.Column({ 2 DataType: Define.DataType.Decimal, 3 DataLength: 11, 4 DecimalPoint: 3 5})
method list: PrimaryKey(opt?: PropertyDefineOption): define a primarykey faster then Column().
Column(opt?: PropertyDefineOption) define a field. and also you can use this function define a primaryKey.
Mapping(opt: PropertyDefineOption) define a mapping. it is used to deal with database foreignKey .
1interface PropertyDefineOption{ 2 DataType?: DataType; 3 DefaultValue?: any; 4 NotAllowNULL?: boolean; 5 DataLength?: number; 6 ColumnName?: string; 7 IsPrimaryKey?: boolean; 8 ForeignKey?: { ForeignTable: string; ForeignColumn: string; IsPhysics?: boolean; }; 9 DecimalPoint?: number; 10 IsIndex?: boolean; 11 Mapping?: string; 12 MappingType?: MappingType; 13 MappingKey?: { FKey: string, MKey?: string } | string; 14} 15 16enum DataType { 17 VARCHAR, 18 TEXT, 19 LONGTEXT, 20 Decimal, 21 INT, 22 BIGINT, 23 BOOL, 24 Array, 25 JSON 26 }
query datas from table, return array.
1let list = await ctx.Person.Where(x => x.age > age, { age }).ToList();
1let list = await ctx.Person.Where(x => x.name.indexOf($args1), { $args1: params.name }).ToList();
using left join:
1let list = await ctx.Person 2 .Join(ctx.Account) 3 .On((m, f) => m.id == f.personId) 4 .Contains<Account>(x => x.amount, values2, ctx.Account) 5 .ToList();
query single entity
1let list = await ctx.Person.First(x => x.name.indexOf($args1), { $args1: params.name });
using transcation:
1await Transaction(new TestDataContext(), async (ctx) => { 2 //insert 10 persons to database; 3 for (let i = 0; i < 10; i++) { 4 let person = new Person(); 5 person.id = Guid.GetGuid(); 6 person.name = "likecheng" + i; 7 person.age = 30 + i; 8 person.birth = new Date("1987-12-1").getTime(); 9 if (i == 9) 10 throw ' transaction error'; 11 await ctx.Create(person); 12 } 13 });
you need install tiny-entity2 global
1$ npm install tiny-entity2 -g
at first you need to create the tinyconfig.json in your project. this file provide some options to command.
1{ 2 "outDir": "./test", 3 "modelLoadPath": [ 4 "./test/models" 5 ], 6 "modelExportPath": [ 7 "./models" 8 ], 9 "ctxExportPath": "", 10 "configFilePath": "./config", 11 "outFileName": "testDataContext.ts", 12 "databaseType": "mysql", 13 "packageName": "../mysql/dataContextMysql" 14}
property description:
use command 'gctx' create a dataContext.ts file.
1tiny --gctx ./tingconfig.json
use command 'gdb' create a new database file .
1tiny --gdb ./tingconfig.json
use comman d 'gop' create a update log and excute to database.
1tiny --gop ./tingconfig.json
you can create different tinyconfig.json for different domain models.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
27 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More