Welcome to ts-sql-query Discussions! #5
juanluispaz
started this conversation in
General
Replies: 3 comments 4 replies
|
Can you publish new version in npm? So we can test it. |
3 replies
|
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 |
1 reply
|
I just published a new beta release with version |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
👋 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.
All reactions