Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Nodejs transaction redesign feature branch #1235

Merged
merged 6 commits into from
Feb 26, 2024
Merged
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -43,6 +43,7 @@
"dependencies": {
"@google-cloud/promisify": "^4.0.0",
"arrify": "^2.0.1",
"async-mutex": "^0.4.0",
"concat-stream": "^2.0.0",
"extend": "^3.0.2",
"google-gax": "^4.0.5",
Expand Down
21 changes: 17 additions & 4 deletions src/request.ts
Expand Up @@ -44,7 +44,7 @@
KeyProto,
ResponseResult,
Entities,
ValueProto,

Check warning on line 47 in src/request.ts

View workflow job for this annotation

GitHub Actions / lint

'ValueProto' is defined but never used

Check warning on line 47 in src/request.ts

View workflow job for this annotation

GitHub Actions / lint

'ValueProto' is defined but never used
} from './entity';
import {
Query,
Expand Down Expand Up @@ -79,7 +79,7 @@
* @class
*/
class DatastoreRequest {
id: string | undefined;
id: string | undefined | Uint8Array | null;
requests_:
| Entity
| {
Expand Down Expand Up @@ -546,6 +546,19 @@
);
}

/**
* Datastore allows you to run aggregate queries by supplying aggregate fields
* which will determine the type of aggregation that is performed.
*
* The query is run, and the results are returned in the second argument of
* the callback provided.
*
* @param {AggregateQuery} query AggregateQuery object.
* @param {RunQueryOptions} options Optional configuration
* @param {function} [callback] The callback function. If omitted, a promise is
* returned.
*
**/
runAggregationQuery(
query: AggregateQuery,
options?: RunQueryOptions
Expand Down Expand Up @@ -596,9 +609,9 @@
const results = res.batch.aggregationResults;
const finalResults = results
.map(
(aggregationResult: any) => aggregationResult.aggregateProperties

Check warning on line 612 in src/request.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 612 in src/request.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
)
.map((aggregateProperties: any) =>

Check warning on line 614 in src/request.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 614 in src/request.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
Object.fromEntries(
new Map(
Object.keys(aggregateProperties).map(key => [
Expand Down Expand Up @@ -933,7 +946,7 @@
callback?: SaveCallback
): void | Promise<CommitResponse> {
const transaction = this.datastore.transaction();
transaction.run(async (err: any) => {

Check warning on line 949 in src/request.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 949 in src/request.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
if (err) {
try {
await transaction.rollback();
Expand Down Expand Up @@ -1157,7 +1170,7 @@
partitionId?: google.datastore.v1.IPartitionId | null;
readOptions?: {
readConsistency?: number;
transaction?: string;
transaction?: string | Uint8Array | null;
readTime?: ITimestamp;
};
}
Expand All @@ -1166,9 +1179,9 @@
keys?: Entity;
transactionOptions?: {
readOnly?: {};
readWrite?: {previousTransaction?: string};
readWrite?: {previousTransaction?: string | Uint8Array | null};
} | null;
transaction?: string | null;
transaction?: string | null | Uint8Array;
mode?: string;
query?: QueryProto;
filter?: string;
Expand Down