Socket
Socket
Sign inDemoInstall

oor

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oor - npm Package Compare versions

Comparing version 1.1.1 to 1.1.3

base/BaseQuery.d.ts

10

package.json
{
"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": {

32

README.md

@@ -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);
```
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