drizzle-orm
Advanced tools
Comparing version 0.10.42 to 0.10.43
@@ -13,3 +13,3 @@ "use strict"; | ||
// public insertStrategy = (value: TCodeType): string => `'${JSON.stringify(value).replace(/'/g, "''")}'::jsonb`; | ||
this.insertStrategy = (value) => `${JSON.stringify(value).replace(/'/g, "''")}`; | ||
this.insertStrategy = (value) => `${JSON.stringify(value)}`; | ||
this.dbName = 'JSONB'; | ||
@@ -16,0 +16,0 @@ } |
@@ -11,3 +11,3 @@ "use strict"; | ||
this.getDbName = () => this.dbName; | ||
this.insertStrategy = (value) => `${value.replace(/'/g, "''")}`; | ||
this.insertStrategy = (value) => `${value}`; | ||
this.dbName = 'TEXT'; | ||
@@ -14,0 +14,0 @@ } |
@@ -11,3 +11,3 @@ "use strict"; | ||
this.getDbName = () => this.dbName; | ||
this.insertStrategy = (value) => `${value.replace(/'/g, "''")}`; | ||
this.insertStrategy = (value) => `${value}`; | ||
this.size = size; | ||
@@ -14,0 +14,0 @@ if (size) { |
{ | ||
"name": "drizzle-orm", | ||
"version": "0.10.42", | ||
"version": "0.10.43", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
206
test.js
"use strict"; | ||
// import { QueryResult } from 'pg'; | ||
// import { drizzle } from '.'; | ||
// import { | ||
// and, eq, greater, isNotNull, less, or, | ||
// } from './builders'; | ||
// import { DB } from './db'; | ||
// import DbConnector from './db/dbConnector'; | ||
// import Session, { ISession } from './db/session'; | ||
// import UsersTable from './docs/tables/usersTable'; | ||
// import ConsoleLogger from './logger/consoleLogger'; | ||
// class KnexSession extends ISession { | ||
// public execute(query: string, values?: any[]): Promise<QueryResult<any>> { | ||
// console.log(query); | ||
// console.log(values); | ||
// return { rows: [] } as any; | ||
// } | ||
// public parametrized(num: number): string { | ||
// return `?${num}`; | ||
// } | ||
// } | ||
// (async () => { | ||
// try { | ||
// // const db = await new DbConnector() | ||
// // .connectionString('postgresql://postgres@127.0.0.1/migrator') | ||
// // .connect(); | ||
// const db = new DB(new KnexSession()); | ||
// // db.useLogger(new ConsoleLogger()); | ||
// const usersTable = new UsersTable(db); | ||
// await usersTable.select().where(or([ | ||
// and([eq(usersTable.role, 'bar'), less(usersTable.phone, 'd')]), | ||
// eq(usersTable.role, 'bar'), | ||
// greater(usersTable.decimalField, 1), | ||
// ])).execute(); | ||
// await usersTable.delete().where(or([ | ||
// and([eq(usersTable.role, 'bar'), less(usersTable.phone, 'd')]), | ||
// eq(usersTable.role, 'bar'), | ||
// greater(usersTable.decimalField, 1), | ||
// ])).execute(); | ||
// await usersTable.update().where(or([ | ||
// and([eq(usersTable.role, 'bar'), less(usersTable.phone, 'd')]), | ||
// eq(usersTable.role, 'bar'), | ||
// greater(usersTable.decimalField, 1), | ||
// ])).set({ | ||
// isArchived: false, | ||
// role: 'bar', | ||
// }).execute(); | ||
// await usersTable.insert({ | ||
// isArchived: false, | ||
// role: 'bar', | ||
// decimalField: 12, | ||
// createdAt: new Date(), | ||
// }).execute(); | ||
// // drizzle.migrator(db).migrate({ migrationFolder: 'drizzle' }); | ||
// // type g = ReturnType<typeof usersTable.updatedAt.getColumnType>['codeType']; | ||
// // type f = ExtractColumnType<typeof usersTable.updatedAt>; | ||
// // type f1 = ExtractColumnType1<f>; | ||
// // const citiesTable = new CitiesTable(db); | ||
// // await usersTable.insert({ | ||
// // }); | ||
// // const res = await citiesTable.update() | ||
// // // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone]) | ||
// // .where(eq(citiesTable.location, 'YR')) | ||
// // .set({ | ||
// // metadata: [{ | ||
// // fallback_image: true, | ||
// // team_image: 'https://files.slack.com/files-pri/T016CCC3FE3-F03461UR9M5/clinic_team_photo_1.jpg?pub_secret=560c098bfb', | ||
// // image_alt_text: 'Generic Physiotherapy Clinic image 1', | ||
// // logo: '', | ||
// // logo_alt_text: '' | ||
// // }], | ||
// // }) | ||
// // // .leftJoin(CitiesTable, UsersTable, (table) => table.userId, (table) => table.id) | ||
// // // .leftJoin(UsersTable, UsersTable, (table) => table.id, (table) => table.id) | ||
// // .execute(); | ||
// // console.log(res); | ||
// // const ser = new MigrationSerializer(); | ||
// // const res = ser.generate([usersTable as AbstractTable<UsersTable>], []); | ||
// // console.log(JSON.stringify(res, null, 2)); | ||
// // const f = { | ||
// // id: count(usersTable.id), | ||
// // }; | ||
// // type d = ExtractModel<typeof f>; | ||
// // const res = await usersTable.select() | ||
// // .leftJoin(UsersTable, (table) => table.id, (table) => table.id) | ||
// // .leftJoin(UsersTable, CitiesTable, (table) => table.id, (table) => table.id) | ||
// // .execute(); | ||
// // const res = await usersTable.select() | ||
// // // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone]) | ||
// // .leftJoin(UsersTable, (table) => table.foundationDate, (table) => table.id) | ||
// // .leftJoin(UsersTable, UsersTable, (table) => table.role, (table) => table.id) | ||
// // .leftJoin(UsersTable, UsersTable, (table) => table.role, (table) => table.id) | ||
// // // .groupBy({ | ||
// // // usersTable: usersTable.id, | ||
// // // firstJoin: [usersTable.id], | ||
// // // secondJoin: usersTable.id, | ||
// // // thirdJoin: usersTable.id, | ||
// // // }) | ||
// // .execute(); | ||
// // console.log(res); | ||
// } catch (e) { | ||
// console.log(e); | ||
// } | ||
// })(); | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const dbConnector_1 = __importDefault(require("./db/dbConnector")); | ||
const session_1 = require("./db/session"); | ||
const usersTable_1 = __importDefault(require("./docs/tables/usersTable")); | ||
class KnexSession extends session_1.ISession { | ||
execute(query, values) { | ||
console.log(query); | ||
console.log(values); | ||
return { rows: [] }; | ||
} | ||
parametrized(num) { | ||
return `${num}?`; | ||
} | ||
} | ||
(async () => { | ||
try { | ||
const db = await new dbConnector_1.default() | ||
.connectionString('postgresql://postgres@127.0.0.1/migrator') | ||
.connect(); | ||
// const db = new DB(new KnexSession()); | ||
// db.useLogger(new ConsoleLogger()); | ||
const usersTable = new usersTable_1.default(db); | ||
// await usersTable.select().where(or([ | ||
// and([eq(usersTable.role, 'bar'), less(usersTable.phone, 'd')]), | ||
// eq(usersTable.role, 'bar'), | ||
// greater(usersTable.decimalField, 1), | ||
// ])).execute(); | ||
// await usersTable.delete().where(or([ | ||
// and([eq(usersTable.role, 'bar'), less(usersTable.phone, 'd')]), | ||
// eq(usersTable.role, 'bar'), | ||
// greater(usersTable.decimalField, 1), | ||
// ])).execute(); | ||
// await usersTable.update().where(or([ | ||
// and([eq(usersTable.role, 'bar'), less(usersTable.phone, 'd')]), | ||
// eq(usersTable.role, 'bar'), | ||
// greater(usersTable.decimalField, 1), | ||
// ])).set({ | ||
// isArchived: false, | ||
// role: 'bar', | ||
// }).execute(); | ||
await usersTable.insert({ | ||
isArchived: false, | ||
role: 'bar', | ||
decimalField: 12, | ||
phone: ' tedss\'t', | ||
media: [' tes\'t', ' t\'es\'t'], | ||
createdAt: new Date(), | ||
}).execute(); | ||
// drizzle.migrator(db).migrate({ migrationFolder: 'drizzle' }); | ||
// type g = ReturnType<typeof usersTable.updatedAt.getColumnType>['codeType']; | ||
// type f = ExtractColumnType<typeof usersTable.updatedAt>; | ||
// type f1 = ExtractColumnType1<f>; | ||
// const citiesTable = new CitiesTable(db); | ||
// await usersTable.insert({ | ||
// }); | ||
// const res = await citiesTable.update() | ||
// // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone]) | ||
// .where(eq(citiesTable.location, 'YR')) | ||
// .set({ | ||
// metadata: [{ | ||
// fallback_image: true, | ||
// team_image: 'https://files.slack.com/files-pri/T016CCC3FE3-F03461UR9M5/clinic_team_photo_1.jpg?pub_secret=560c098bfb', | ||
// image_alt_text: 'Generic Physiotherapy Clinic image 1', | ||
// logo: '', | ||
// logo_alt_text: '' | ||
// }], | ||
// }) | ||
// // .leftJoin(CitiesTable, UsersTable, (table) => table.userId, (table) => table.id) | ||
// // .leftJoin(UsersTable, UsersTable, (table) => table.id, (table) => table.id) | ||
// .execute(); | ||
// console.log(res); | ||
// const ser = new MigrationSerializer(); | ||
// const res = ser.generate([usersTable as AbstractTable<UsersTable>], []); | ||
// console.log(JSON.stringify(res, null, 2)); | ||
// const f = { | ||
// id: count(usersTable.id), | ||
// }; | ||
// type d = ExtractModel<typeof f>; | ||
// const res = await usersTable.select() | ||
// .leftJoin(UsersTable, (table) => table.id, (table) => table.id) | ||
// .leftJoin(UsersTable, CitiesTable, (table) => table.id, (table) => table.id) | ||
// .execute(); | ||
// const res = await usersTable.select() | ||
// // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone]) | ||
// .leftJoin(UsersTable, (table) => table.foundationDate, (table) => table.id) | ||
// .leftJoin(UsersTable, UsersTable, (table) => table.role, (table) => table.id) | ||
// .leftJoin(UsersTable, UsersTable, (table) => table.role, (table) => table.id) | ||
// // .groupBy({ | ||
// // usersTable: usersTable.id, | ||
// // firstJoin: [usersTable.id], | ||
// // secondJoin: usersTable.id, | ||
// // thirdJoin: usersTable.id, | ||
// // }) | ||
// .execute(); | ||
// console.log(res); | ||
} | ||
catch (e) { | ||
console.log(e); | ||
} | ||
})(); |
333105
6292