GeezerVison is showing github.com — feat: Support for using multiple databases in datastore (#1090) · googleapis/google-cloud-node@7c9fd49
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: handwritten/datastore/package.json +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 59 | 59 | "@types/node": "^20.4.9", | 60 | 60 | "@types/proxyquire": "^1.3.28", | 61 | 61 | "@types/sinon": "^10.0.0", | | 62 | + "async": "^3.2.4", | 62 | 63 | "c8": "^8.0.1", | 63 | 64 | "gapic-tools": "^0.2.0", | 64 | 65 | "gts": "^5.0.0", | |
Collapse file Copy file name to clipboardExpand all lines: handwritten/datastore/src/index.ts +12Lines changed: 12 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -700,6 +700,16 @@ class Datastore extends DatastoreRequest { | 700 | 700 | ); | 701 | 701 | } | 702 | 702 |
| | 703 | + /** | | 704 | + * Gets the database id that all requests will be run against. | | 705 | + * | | 706 | + * @returns {string} The database id that the current client is set to that | | 707 | + * requests will run against. | | 708 | + */ | | 709 | + getDatabaseId(): string | undefined { | | 710 | + return this.options.databaseId; | | 711 | + } | | 712 | + | 703 | 713 | getProjectId(): Promise<string> { | 704 | 714 | return this.auth.getProjectId(); | 705 | 715 | } | @@ -1818,6 +1828,7 @@ promisifyAll(Datastore, { | 1818 | 1828 | 'double', | 1819 | 1829 | 'isDouble', | 1820 | 1830 | 'geoPoint', | | 1831 | + 'getDatabaseId', | 1821 | 1832 | 'getProjectId', | 1822 | 1833 | 'isGeoPoint', | 1823 | 1834 | 'index', | @@ -1898,6 +1909,7 @@ export interface DatastoreOptions extends GoogleAuthOptions { | 1898 | 1909 | namespace?: string; | 1899 | 1910 | apiEndpoint?: string; | 1900 | 1911 | sslCreds?: ChannelCredentials; | | 1912 | + databaseId?: string; | 1901 | 1913 | } | 1902 | 1914 |
| 1903 | 1915 | export interface KeyToLegacyUrlSafeCallback { | |
Collapse file Copy file name to clipboardExpand all lines: handwritten/datastore/src/request.ts +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -992,6 +992,10 @@ class DatastoreRequest { | 992 | 992 | } | 993 | 993 | } | 994 | 994 |
| | 995 | + if (datastore.options && datastore.options.databaseId) { | | 996 | + reqOpts.databaseId = datastore.options.databaseId; | | 997 | + } | | 998 | + | 995 | 999 | if (method === 'rollback') { | 996 | 1000 | reqOpts.transaction = this.id; | 997 | 1001 | } | @@ -1143,6 +1147,7 @@ export interface RequestConfig { | 1143 | 1147 | reqOpts?: RequestOptions; | 1144 | 1148 | } | 1145 | 1149 | export interface SharedQueryOptions { | | 1150 | + databaseId?: string; | 1146 | 1151 | projectId?: string; | 1147 | 1152 | partitionId?: google.datastore.v1.IPartitionId | null; | 1148 | 1153 | readOptions?: { | |
|