Comparing version 1.1.1 to 1.1.3
{ | ||
"name": "oor", | ||
"version": "1.1.1", | ||
"version": "1.1.3", | ||
"author": "ada87", | ||
@@ -17,8 +17,6 @@ "keywords": [ | ||
"license": "MIT", | ||
"files": [ | ||
"dist" | ||
], | ||
"main": "dist/pg/index.js", | ||
"main": "pg/index.js", | ||
"scripts": { | ||
"test": "node -r ts-node/register test.ts" | ||
"test": "node -r ts-node/register script.ts", | ||
"pub": "node -r ts-node/register script.ts --pub" | ||
}, | ||
@@ -25,0 +23,0 @@ "devDependencies": { |
@@ -36,4 +36,4 @@ # OOR | ||
import { setup } from 'oor'; | ||
import { Client } from 'pg'; | ||
const pg = new Client({}) | ||
import { Pool } from 'pg'; | ||
const pg = new Pool({...}) | ||
setup({ provider: () => pg }) | ||
@@ -49,5 +49,5 @@ ``` | ||
// Line 2 : Define 'Realtion Mapping' & 'Mapping Schema' & 'Entity Type (Line3)' together by one Funtion. | ||
// Schema has some usage , some lib(like fastify,ajv.) support schema。 | ||
// https://www.npmjs.com/package/@sinclair/typebox | ||
// Line 2 : Build a Schema | ||
// Schema can be used for validate、check, @see @sinclair/typebox | ||
// Some web framework support this schema, like fastify | ||
export const UserSchema = UType.Table({ | ||
@@ -76,3 +76,3 @@ id: UType.Number(), | ||
```typescript | ||
// Fetch all user | ||
// Fetch all Users | ||
const result = await User.all(); | ||
@@ -86,7 +86,7 @@ console.log(result); | ||
sex: false, | ||
address: 'randmo', | ||
address: 'address', | ||
salary: 1221.2, | ||
}); | ||
console.log('Insert Result', insertResult) | ||
let userId = insertResult.id as number; | ||
let userId = insertResult.id; | ||
@@ -98,8 +98,8 @@ | ||
// Update | ||
await new Promise(r => setTimeout(r, 1200)); // wait , notice last_update value | ||
let isUpdate = await User.update({ id: userId, age: 60, }); // change Age | ||
await new Promise(r => setTimeout(r, 1234)); // WaitTime effect column "last_modify" | ||
let isUpdate = await User.update({ id: userId, age: 60, }); // Update Age | ||
console.log('Update is Success ? : ', isUpdate == 1); | ||
const afterUpdate = await User.getById(userId); | ||
console.log('After Update', afterUpdate) | ||
console.log('After Update', afterUpdate); // lastModify & age is updated | ||
@@ -110,3 +110,2 @@ // Delete | ||
await setTimeout(r => r, 1000); // wait , notice last_update value | ||
const afterDelete = await User.getById(userId); | ||
@@ -116,8 +115,9 @@ console.log('After Delete', afterDelete) | ||
// Execue custom SQL Sentence. | ||
const result = await User.sql(`SELECT XXX | ||
FROM YYY | ||
WHERE ZZZ = $1 | ||
ORDER BY $2 $3`,['value','id','DESC']); | ||
// sql method will call (pgClient).query(...arguments) | ||
const result = await User.sql( | ||
`SELECT XXX FROM YYY WHERE ZZZ = $1 ORDER BY $2 $3`, | ||
['value','id','DESC'] | ||
); | ||
console.log(result); | ||
``` | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91461
51
2134
1