-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip * fix * rm commented-out code * extract to file * add comments * docs * fix * upd * test * upd * flutter_version * test * ? * blessrng * blessRNG * experiment * up * ultra bless * . * maybe closer * not bruh * please * <> * 777 * pls * ultra please * pls * hope * fix * fix * versions * fix * init? * done? * fix * upd * part * add placeholders * exports * fixes * fixes * more fixes * source * todo * clientOptions * info * remove things that are implemented * simplify checklist * align * extract checklist * more implemented * upd * upd * Savepoint * fix comments * promise docs * savepoint comments * ClientOptions comments * hosttype * partialconnectionoptions upd * partialTLSOptions * uncomment * progress * partially resolve queryObject * upd * upd * big upd * fix * split by files * init * CommandType * notice * ResultType * working type * placeholders * working * more consistent comments * rowdescription * query * split by files * queryObjectOptions * uint8 * init * mini upd * working * remove generic * upd * init * upd * init * rm duplicate * restore * restore order * part * more prope * upd * fix * todos * upd * constructor * parse * todo * upd * upd * fix comments * upd * upd * upd * constructor * upd * upd * export * tls options * finish? * upd * last * upd * upd * upd * revert * revert * upd * upd * fix * restore * add comments * comments * update unimplemented * upd * upd * upd * upd * transaction * fin * upd * impl * seemps good * upd * exports
- Loading branch information
1 parent
3cb0548
commit 9a75f04
Showing
10 changed files
with
269 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
import 'dart:js_interop'; | ||
import 'dart:js_util'; | ||
|
||
import 'package:deno_postgres_interop/src/client_options.dart'; | ||
import 'package:deno_postgres_interop/src/query_client.dart'; | ||
|
||
/// [deno-postgres@v0.17.0/Client](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Client). | ||
@JS() | ||
class Client extends QueryClient { | ||
/// [deno-postgres@v0.17.0/Client/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Client#ctor_0). | ||
external factory Client(String dbUrl); | ||
|
||
/// [deno-postgres@v0.17.0/Client/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Client#ctor_0). | ||
factory Client.config(ClientOptions config) => | ||
callConstructor('Client', [config]); | ||
|
||
/// [deno-postgres@v0.17.0/Client/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Client#ctor_0). | ||
factory Client.empty() => callConstructor('Client', null); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import 'dart:js_interop'; | ||
import 'dart:js_util'; | ||
|
||
import 'package:deno_postgres_interop/src/client_configuration.dart'; | ||
import 'package:deno_postgres_interop/src/promise.dart'; | ||
import 'package:deno_postgres_interop/src/query.dart'; | ||
import 'package:deno_postgres_interop/src/query_result.dart'; | ||
import 'package:deno_postgres_interop/src/transport.dart'; | ||
import 'package:deno_postgres_interop/src/util.dart'; | ||
|
||
/// [deno-postgres@v0.17.0/Connection](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection). | ||
@JS() | ||
class Connection { | ||
/// [deno-postgres@v0.17.0/Connection/connected](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#accessor_pid). | ||
external int get pid; | ||
|
||
/// [deno-postgres@v0.17.0/Connection/constructor](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#ctor_0). | ||
factory Connection({ | ||
required ClientConfiguration connectionParams, | ||
required Future<void> Function() disconnectionCallback, | ||
}) => | ||
callConstructor( | ||
'Connection', | ||
[connectionParams, () => futureToPromise(disconnectionCallback())], | ||
); | ||
} | ||
|
||
/// [deno-postgres@v0.17.0/Connection](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection). | ||
extension ConnectionProps on Connection { | ||
/// [deno-postgres@v0.17.0/Connection/connected](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#prop_connected). | ||
bool get isConnected => getProperty(this, 'connected'); | ||
|
||
/// [deno-postgres@v0.17.0/Connection/tls](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#accessor_tls). | ||
bool get isCarriedOverTLS => getProperty(this, 'tls'); | ||
|
||
/// [deno-postgres@v0.17.0/Connection/transport](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#accessor_transport). | ||
Transport get transport => Transport.parse(getProperty(this, 'transport')); | ||
|
||
/// [deno-postgres@v0.17.0/Connection/end](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#method_end_0). | ||
Future<void> end() => callFutureMethod(this, 'end'); | ||
|
||
/// [deno-postgres@v0.17.0/Connection/query](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#method_query_0). | ||
/// [deno-postgres@v0.17.0/Connection/query](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#method_query_1). | ||
Future<T> queryArray<T extends QueryResult>(Query query) => | ||
callFutureMethod(this, 'query', [query]); | ||
|
||
/// [deno-postgres@v0.17.0/Connection/startup](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#method_startup_0). | ||
Future<void> startup({required bool isReconnection}) => | ||
callFutureMethod(this, 'startup', [isReconnection]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'dart:js_interop'; | ||
import 'dart:js_util'; | ||
|
||
typedef _Resolver<T> = void Function(T result); | ||
typedef _Executor<T> = void Function(_Resolver<T> resolve, Function reject); | ||
|
||
/// JS [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) interop. | ||
@JS() | ||
class Promise<T> { | ||
/// [js/Promise/constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/Promise). | ||
external Promise(_Executor<T> executor); | ||
} | ||
|
||
/// Convert darts [Future] to js' [Promise]. | ||
Promise<T> futureToPromise<T>(Future<T> future) { | ||
return Promise<T>( | ||
allowInterop((resolve, reject) { | ||
future.then(resolve, onError: reject); | ||
}), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'dart:js_interop'; | ||
import 'dart:js_util'; | ||
|
||
import 'package:deno_postgres_interop/src/promise.dart'; | ||
import 'package:deno_postgres_interop/src/util.dart'; | ||
|
||
/// [deno-postgres@v0.17.0/Savepoint](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Savepoint). | ||
@JS() | ||
class Savepoint { | ||
/// [deno-postgres@v0.17.0/Savepoint/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Savepoint#ctor_0). | ||
factory Savepoint( | ||
String name, | ||
Future<void> Function(String name) updateCallback, | ||
Future<void> Function(String name) releaseCallback, | ||
) => | ||
callConstructor('Savepoint', [ | ||
name, | ||
(String name) => futureToPromise(updateCallback(name)), | ||
(String name) => futureToPromise(releaseCallback(name)), | ||
]); | ||
} | ||
|
||
/// [deno-postgres@v0.17.0/Savepoint](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Savepoint). | ||
extension SavepointProps on Savepoint { | ||
/// [deno-postgres@v0.17.0/Savepoint/instances](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Savepoint#accessor_instances). | ||
int get instancesCount => getProperty(this, 'instances'); | ||
|
||
/// [deno-postgres@v0.17.0/Savepoint/instances](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Savepoint#method_release_0). | ||
Future<void> release() => callFutureMethod(this, 'release'); | ||
|
||
/// [deno-postgres@v0.17.0/Savepoint/instances](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Savepoint#method_update_0). | ||
Future<void> update() => callFutureMethod(this, 'update'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'dart:js_interop'; | ||
import 'dart:js_util'; | ||
|
||
import 'package:deno_postgres_interop/src/transport.dart'; | ||
|
||
/// [deno-postgres@v0.17.0/Session](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Session). | ||
@JS() | ||
class Session { | ||
/// [deno-postgres@v0.17.0/Session/pid](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Session#prop_pid) | ||
external int? get pid; | ||
|
||
/// [deno-postgres@v0.17.0/Session/tls](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Session#prop_tls) | ||
external bool? get tls; | ||
} | ||
|
||
/// [deno-postgres@v0.17.0/Session](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Session). | ||
extension SessionProps on Session { | ||
/// [deno-postgres@v0.17.0/Session/current_transaction](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Session#prop_current_transaction) | ||
String? get currentTransacton => getProperty(this, 'current_transaction'); | ||
|
||
/// [deno-postgres@v0.17.0/Session/transport](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Session#prop_transport) | ||
Transport? get transport { | ||
final string = getProperty<String?>(this, 'transport'); | ||
|
||
return string == null ? null : Transport.parse(string); | ||
} | ||
} |
Oops, something went wrong.