[@google-cloud/datastore]: Update definitions for v1.3 (#22504)

This commit is contained in:
antoine beauᵛᵃᴵˢ⁻lacᵃˢˢᵉ
2018-01-02 15:43:28 -05:00
committed by Mohamed Hegazy
parent 034f4b7343
commit 20bad0bb87
2 changed files with 25 additions and 4 deletions

View File

@@ -35,12 +35,17 @@ ds.determineBaseUrl_('http://localhost:8081');
// Keys components creation:
const dsInt: DatastoreInt = ds.int(42);
const isInt = ds.isInt(dsInt);
const dsDouble: DatastoreDouble = ds.double('3.14');
const isDouble = ds.isDouble(dsDouble);
const dsGeopoint: DatastoreGeopoint = ds.geoPoint({latitude: 0, longitude: 0});
const isGeoPoint = ds.isGeoPoint(dsGeopoint);
// Keys creation:
const keyPath: DatastoreKeyPath = [kind, 'Google', 'Department', dsInt];
const key: DatastoreKey = ds.key(keyPath);
const isKey = ds.isKey(key);
const ancestorKey: DatastoreKey = ds.key(['ParentCompany', 'Alphabet']);
const keyWithOptions: DatastoreKey = ds.key({
namespace: 'special-namespace',

View File

@@ -1,5 +1,5 @@
// Type definitions for @google-cloud/datastore 1.1
// Project: https://github.com/GoogleCloudPlatform/google-cloud-node/tree/master/packages/datastore
// Type definitions for @google-cloud/datastore 1.3
// Project: https://github.com/googleapis/nodejs-datastore
// Definitions by: Antoine Beauvais-Lacasse <https://github.com/beaulac>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
@@ -20,7 +20,11 @@ declare module '@google-cloud/datastore' {
DatastoreCoords,
OneOrMany
} from '@google-cloud/datastore/entity';
import { DatastoreRequest as DatastoreRequest_, CommitCallback, CommitResult } from '@google-cloud/datastore/request';
import {
DatastoreRequest as DatastoreRequest_,
CommitCallback,
CommitResult
} from '@google-cloud/datastore/request';
import {
Query as DatastoreQuery,
MoreResultsAfterCursor,
@@ -51,12 +55,20 @@ declare module '@google-cloud/datastore' {
int(value: string | number): DatastoreInt;
isInt(value: any): value is DatastoreInt;
double(value: string | number): DatastoreDouble;
isDouble(value: any): value is DatastoreDouble;
geoPoint(coordinates: DatastoreCoords): DatastoreGeopoint;
isGeoPoint(value: any): value is DatastoreGeopoint;
key(pathOrOptions: DatastoreKeyPath | DatastoreKeyOptions): DatastoreKey;
isKey(value: any): value is DatastoreKey;
determineBaseUrl_(customApiEndpoint?: string): void;
}
@@ -84,6 +96,7 @@ declare module '@google-cloud/datastore/entity' {
interface DatastoreInt {
value: string;
}
interface DatastoreDouble {
value: string;
}
@@ -92,6 +105,7 @@ declare module '@google-cloud/datastore/entity' {
latitude: number;
longitude: number;
}
interface DatastoreGeopoint {
value: DatastoreCoords;
}
@@ -297,6 +311,8 @@ declare module '@google-cloud/datastore/transaction' {
type RollbackCallback = (err: Error, rollbackResponse: {}) => void;
type RollbackResult = [{}];
type TransactionCallback = (err: Error, tx: DatastoreTransaction, beginTxResponse: BeginTransactionResponse) => void;
type TransactionCallback = (err: Error,
tx: DatastoreTransaction,
beginTxResponse: BeginTransactionResponse) => void;
type TransactionResult = [DatastoreTransaction, BeginTransactionResponse];
}