Skip to content

Commit 15b56da

Browse files
QueryResult (#11)
* 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
1 parent 3b3efee commit 15b56da

File tree

5 files changed

+112
-1
lines changed

5 files changed

+112
-1
lines changed

lib/src/encoded_arg.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// [[email protected]/EncodedArg](https://deno.land/x/[email protected]/query/encode.ts?s=EncodedArg).
2+
typedef EncodedArg = dynamic;

lib/src/query.dart

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,47 @@
11
import 'dart:js_interop';
22
import 'dart:js_util';
33

4+
import 'package:deno_postgres_interop/src/encoded_arg.dart';
5+
import 'package:deno_postgres_interop/src/query_object.dart';
6+
import 'package:deno_postgres_interop/src/query_object_options.dart';
47
import 'package:deno_postgres_interop/src/result_type.dart';
58

69
/// [[email protected]/Query](https://deno.land/x/[email protected]/query/query.ts?s=Query).
710
@JS()
8-
class Query {}
11+
class Query {
12+
/// [[email protected]/Query/args](https://deno.land/x/[email protected]/query/query.ts?s=Query#prop_args).
13+
external List<EncodedArg> args;
14+
15+
/// [[email protected]/Query/args](https://deno.land/x/[email protected]/query/query.ts?s=Query#prop_fields).
16+
external List<String>? get fields;
17+
18+
/// [[email protected]/Query/args](https://deno.land/x/[email protected]/query/query.ts?s=Query#prop_text).
19+
external String get text;
20+
21+
/// [[email protected]/Query/constructor](https://deno.land/x/[email protected]/query/query.ts?s=Query#ctor_0).
22+
/// [[email protected]/Query/constructor](https://deno.land/x/[email protected]/query/query.ts?s=Query#ctor_2).
23+
factory Query.withConfig({
24+
required QueryObjectOptions config,
25+
required ResultType resultType,
26+
QueryArguments? args,
27+
}) =>
28+
callConstructor('Query', [config, resultType, args]) as Query;
29+
30+
/// [[email protected]/Query/constructor](https://deno.land/x/[email protected]/query/query.ts?s=Query#ctor_1).
31+
/// [[email protected]/Query/constructor](https://deno.land/x/[email protected]/query/query.ts?s=Query#ctor_2).
32+
factory Query.withArgs({
33+
required String text,
34+
required ResultType resultType,
35+
QueryArguments? args,
36+
}) =>
37+
callConstructor('Query', [text, resultType, args]) as Query;
38+
}
939

1040
/// [[email protected]/Query](https://deno.land/x/[email protected]/query/query.ts?s=Query).
1141
extension QueryProps on Query {
42+
/// [[email protected]/Query/args](https://deno.land/x/[email protected]/query/query.ts?s=Query#prop_camelcase).
43+
bool? get isCamelCase => getProperty(this, 'camelcase');
44+
1245
/// [[email protected]/Query/result_type](https://deno.land/x/[email protected]/query/query.ts?s=Query#prop_result_type).
1346
ResultType get resultType =>
1447
ResultType.values[getProperty(this, 'result_type')];

lib/src/query_object_options.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'dart:js_interop';
2+
import 'dart:js_util';
3+
4+
import 'package:deno_postgres_interop/src/query_options.dart';
5+
6+
/// [[email protected]/QueryObjectOptions](https://deno.land/x/[email protected]/query/query.ts?s=QueryObjectOptions).
7+
@JS()
8+
class QueryObjectOptions extends QueryOptions {
9+
/// [[email protected]/QueryObjectOptions/fields](https://deno.land/x/[email protected]/query/query.ts?s=QueryObjectOptions#prop_fields).
10+
external List<String>? get fields;
11+
12+
/// [[email protected]/QueryObjectOptions](https://deno.land/x/[email protected]/query/query.ts?s=QueryObjectOptions).
13+
factory QueryObjectOptions({List<String>? fields, bool? isCamelCase}) =>
14+
jsify(
15+
{
16+
if (isCamelCase != null) 'camelcase': isCamelCase,
17+
if (fields != null) 'fields': fields,
18+
},
19+
) as QueryObjectOptions;
20+
}
21+
22+
/// [[email protected]/QueryObjectOptions](https://deno.land/x/[email protected]/query/query.ts?s=QueryObjectOptions).
23+
extension QueryObjectOptionsProps on QueryObjectOptions {
24+
/// [[email protected]/QueryObjectOptions/camelcase](https://deno.land/x/[email protected]/query/query.ts?s=QueryObjectOptions#prop_camelcase).
25+
bool? get isCamelCase => getProperty(this, 'camelcase');
26+
}

lib/src/query_options.dart

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import 'dart:js_interop';
2+
import 'dart:js_util';
3+
4+
import 'package:deno_postgres_interop/deno_postgres_interop.dart';
5+
import 'package:deno_postgres_interop/src/encoded_arg.dart';
6+
7+
/// [[email protected]/QueryOptions](https://deno.land/x/[email protected]/query/query.ts?s=QueryOptions).
8+
@JS()
9+
class QueryOptions {
10+
/// [[email protected]/QueryOptions/args](https://deno.land/x/[email protected]/query/query.ts?s=QueryOptions#prop_args).
11+
external QueryArguments? get args;
12+
13+
/// [[email protected]/QueryOptions/encoder](https://deno.land/x/[email protected]/query/query.ts?s=QueryOptions#prop_encoder).
14+
external EncodedArg Function(dynamic arg)? get encoder;
15+
16+
/// [[email protected]/QueryOptions/name](https://deno.land/x/[email protected]/query/query.ts?s=QueryOptions#prop_name).
17+
external String? get name;
18+
19+
/// [[email protected]/QueryOptions/text](https://deno.land/x/[email protected]/query/query.ts?s=QueryOptions#prop_text.
20+
external String get text;
21+
22+
/// [[email protected]/QueryOptions](https://deno.land/x/[email protected]/query/query.ts?s=QueryOptions).
23+
factory QueryOptions({
24+
required String text,
25+
QueryArguments? args,
26+
EncodedArg Function(dynamic arg)? encoder,
27+
String? name,
28+
}) =>
29+
jsify({
30+
if (args != null) 'args': args,
31+
if (encoder != null) 'encoder': encoder,
32+
if (name != null) 'name': name,
33+
'text': text,
34+
}) as QueryOptions;
35+
}

lib/src/query_result.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import 'package:deno_postgres_interop/src/row_description.dart';
99
/// [[email protected]/QueryResult](https://deno.land/x/[email protected]/query/query.ts?s=QueryResult).
1010
@JS()
1111
class QueryResult {
12+
/// [[email protected]/QueryResult/rowCount](https://deno.land/x/[email protected]/query/query.ts?s=QueryResult#prop_rowCount).
13+
external int? get rowCount;
14+
1215
/// [[email protected]/QueryResult/warnings](https://deno.land/x/[email protected]/query/query.ts?s=QueryResult#prop_warnings).
1316
external List<Notice> get warnings;
1417

@@ -17,10 +20,22 @@ class QueryResult {
1720

1821
/// [[email protected]/QueryResult/rowDescription](https://deno.land/x/[email protected]/query/query.ts?s=QueryResult#accessor_rowDescription).
1922
external RowDescription? get rowDescription;
23+
24+
/// [[email protected]/QueryResult/constructor](https://deno.land/x/[email protected]/query/query.ts?s=QueryResult#ctor_0).
25+
external factory QueryResult(Query query);
26+
27+
/// [[email protected]/QueryResult/handleCommandComplete](https://deno.land/x/[email protected]/query/query.ts?s=QueryResult#method_handleCommandComplete_0).
28+
external void handleCommandComplete(String commandTag);
29+
30+
/// [[email protected]/QueryResult/loadColumnDescriptions](https://deno.land/x/[email protected]/query/query.ts?s=QueryResult#method_loadColumnDescriptions_0).
31+
external void loadColumnDescriptions(RowDescription description);
2032
}
2133

2234
/// [[email protected]/QueryResult](https://deno.land/x/[email protected]/query/query.ts?s=QueryResult).
2335
extension QueryResultProps on QueryResult {
36+
/// [[email protected]/QueryResult/insertRow](https://deno.land/x/[email protected]/query/query.ts?s=QueryResult#method_insertRow_0).
37+
void insertRow(List<List<int>> row) => callMethod(this, 'insertRow', [row]);
38+
2439
/// [[email protected]/QueryResult/command](https://deno.land/x/[email protected]/query/query.ts?s=QueryResult#prop_command).
2540
CommandType get command => CommandType.parse(
2641
getProperty(this, 'command'),

0 commit comments

Comments
 (0)