You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Feature to return resultset metadata on the low level API
to help dynamic applications to analise column declared data types
that can be "different" from storage datatypes, like datetime or booleans
Copy file name to clipboardExpand all lines: README.md
+55-3Lines changed: 55 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,12 +33,46 @@ Inspired/compatible with [react-native-sqlite-storage](https://github.com/andpor
33
33
34
34
```typescript
35
35
interfaceQueryResult {
36
-
status:0|1; // 0 for correct execution
37
-
message:string; // if status === 1, here you will find error description
38
-
rows:any[];
36
+
status?:0|1; // 0 for correct execution
39
37
insertId?:number;
38
+
rowsAffected:number;
39
+
message?:string;
40
+
rows?: {
41
+
/** Raw array with all dataset */
42
+
_array:any[];
43
+
/** The lengh of the dataset */
44
+
length:number;
45
+
/** A convenience function to acess the index based the row object
46
+
* @paramidx the row index
47
+
* @returns the row structure identified by column names
48
+
*/
49
+
item: (idx:number) =>any;
50
+
};
51
+
/**
52
+
* Query metadata, avaliable only for select query results
53
+
*/
54
+
metadata?:ResultsetMetadata;
40
55
}
41
56
57
+
/**
58
+
* Column metadata
59
+
* Describes some information about columns fetched by the query
60
+
*/
61
+
declaretypeColumnMetadata= {
62
+
/** The name used for this column for this resultset */
63
+
columnName:string;
64
+
/** The declared column type for this column, when fetched directly from a table or a View resulting from a table column. "UNKNOWN" for dynamic values, like function returned ones. */
65
+
columnDeclaredType:string;
66
+
/**
67
+
* The index for this column for this resultset*/
68
+
columnIndex:number;
69
+
};
70
+
71
+
/**
72
+
* Collection of columns that represents the resultset of a query
73
+
*/
74
+
declaretypeResultsetMetadata=ColumnMetadata[];
75
+
42
76
interfaceBatchQueryResult {
43
77
status?:0|1;
44
78
rowsAffected?:number;
@@ -116,6 +150,24 @@ if (!result.status) {
116
150
}
117
151
```
118
152
153
+
In some scenarios, dynamic applications may need to get some metadata information about the returned resultset.
154
+
This can be done testing the returned data directly, but in some cases may not be enought, like when data is stored outside
155
+
storage datatypes, like booleans or datetimes. When fetching data directly from tables or views linked to table columns, SQLite is able
156
+
to identify the table declared types:
157
+
158
+
```typescript
159
+
let result =sqlite.executeSql('myDatabase', 'SELECT int_column_1, bol_column_2 FROM sometable');
Copy file name to clipboardExpand all lines: src/index.ts
+23Lines changed: 23 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -40,8 +40,31 @@ interface QueryResult {
40
40
*/
41
41
item: (idx: number)=>any;
42
42
};
43
+
/**
44
+
* Query metadata, avaliable only for select query results
45
+
*/
46
+
metadata?: ResultsetMetadata;
43
47
}
44
48
49
+
/**
50
+
* Column metadata
51
+
* Describes some information about columns fetched by the query
52
+
*/
53
+
declaretypeColumnMetadata={
54
+
/** The name used for this column for this resultset */
55
+
columnName: string;
56
+
/** The declared column type for this column, when fetched directly from a table or a View resulting from a table column. "UNKNOWN" for dynamic values, like function returned ones. */
57
+
columnDeclaredType: string;
58
+
/**
59
+
* The index for this column for this resultset*/
60
+
columnIndex: number;
61
+
};
62
+
63
+
/**
64
+
* Collection of columns that represents the resultset of a query
0 commit comments