Welcome to ts-sql-query Discussions! #5
Replies: 3 comments 4 replies
-
Can you publish new version in npm? So we can test it. |
Beta Was this translation helpful? Give feedback.
-
Now the doc is split into many chunks -- Yes, it's just one markdown, but things indeed is split separate... New bee like me need a easy example like: // db.ts
import { Pool } from 'pg';
import { Table } from 'ts-sql-query/Table';
import { PostgreSqlConnection } from 'ts-sql-query/connections/PostgreSqlConnection';
import { PgPoolQueryRunner } from 'ts-sql-query/queryRunners/PgPoolQueryRunner';
class DBConection extends PostgreSqlConnection<DBConection, 'DBConnection'> {}
const pool = new Pool({
connectionString: 'postgresql://127.0.0.1:5432/sql_turotial',
});
export const countries = new (class extends Table<DBConection> {
country_id = this.primaryKey('country_id', 'string');
country_name = this.optionalColumn('country_name', 'string');
region_id = this.column('region_id', 'int');
constructor() {
super('countries'); // table name in the database
}
})();
export const regions = new (class extends Table<DBConection> {
region_id = this.autogeneratedPrimaryKey('region_id', 'int');
region_name = this.optionalColumn('region_name', 'string');
constructor() {
super('regions'); // table name in the database
}
})();
export const conn = new DBConection(new PgPoolQueryRunner(pool));
// index.ts
import * as db from './db';
(async () => {
const countries = await db.conn
.selectFrom(db.countries)
.select({ id: db.countries.country_id, name: db.countries.country_name })
.executeSelectMany();
console.log(countries);
process.exit();
})(); This example is for |
Beta Was this translation helpful? Give feedback.
-
I just published a new beta release with version |
Beta Was this translation helpful? Give feedback.
-
👋 Welcome!
We’re using Discussions as a place to connect with other members of our community. We hope that you:
build together 💪.
To get started, comment below with an introduction of yourself and tell us about what you do with this community.
Beta Was this translation helpful? Give feedback.
All reactions