nuxt-users 1.1.3 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,58 +0,0 @@
1
- import pg from 'pg';
2
- import { B as BoundableStatement } from '../shared/nuxt-users.C9d5M6B1.mjs';
3
-
4
- function postgresqlConnector(opts) {
5
- let _client;
6
- function getClient() {
7
- if (_client) {
8
- return _client;
9
- }
10
- const client = new pg.Client("url" in opts ? opts.url : opts);
11
- _client = client.connect().then(() => {
12
- _client = client;
13
- return _client;
14
- });
15
- return _client;
16
- }
17
- const query = async (sql, params) => {
18
- const client = await getClient();
19
- return client.query(normalizeParams(sql), params);
20
- };
21
- return {
22
- name: "postgresql",
23
- dialect: "postgresql",
24
- getInstance: () => getClient(),
25
- exec: (sql) => query(sql),
26
- prepare: (sql) => new StatementWrapper(sql, query)
27
- };
28
- }
29
- function normalizeParams(sql) {
30
- let i = 0;
31
- return sql.replace(/\?/g, () => `$${++i}`);
32
- }
33
- class StatementWrapper extends BoundableStatement {
34
- #query;
35
- #sql;
36
- constructor(sql, query) {
37
- super();
38
- this.#sql = sql;
39
- this.#query = query;
40
- }
41
- async all(...params) {
42
- const res = await this.#query(this.#sql, params);
43
- return res.rows;
44
- }
45
- async run(...params) {
46
- const res = await this.#query(this.#sql, params);
47
- return {
48
- success: true,
49
- ...res
50
- };
51
- }
52
- async get(...params) {
53
- const res = await this.#query(this.#sql, params);
54
- return res.rows[0];
55
- }
56
- }
57
-
58
- export { postgresqlConnector as default };
@@ -1,31 +0,0 @@
1
- class BoundableStatement {
2
- _statement;
3
- constructor(rawStmt) {
4
- this._statement = rawStmt;
5
- }
6
- bind(...params) {
7
- return new BoundStatement(this, params);
8
- }
9
- }
10
- class BoundStatement {
11
- #statement;
12
- #params;
13
- constructor(statement, params) {
14
- this.#statement = statement;
15
- this.#params = params;
16
- }
17
- bind(...params) {
18
- return new BoundStatement(this.#statement, params);
19
- }
20
- all() {
21
- return this.#statement.all(...this.#params);
22
- }
23
- run() {
24
- return this.#statement.run(...this.#params);
25
- }
26
- get() {
27
- return this.#statement.get(...this.#params);
28
- }
29
- }
30
-
31
- export { BoundableStatement as B };