aboutsummaryrefslogtreecommitdiff
path: root/src/server/database.ts
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-09-26 23:13:42 -0400
committerSam Wilkins <samwilkins333@gmail.com>2019-09-26 23:13:42 -0400
commit2553bafde4a6d492512f0a5dfd25f5bd407af929 (patch)
treea8d144840c7de9255de1ec121ed66e350245ebf0 /src/server/database.ts
parent2e61db73a1fcba3b87cc84a7d1af51617f6a02f6 (diff)
parent087f96367936f33743a304b3446b24074290c367 (diff)
merged with master again
Diffstat (limited to 'src/server/database.ts')
-rw-r--r--src/server/database.ts11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/server/database.ts b/src/server/database.ts
index 969437818..d2375ebd9 100644
--- a/src/server/database.ts
+++ b/src/server/database.ts
@@ -3,6 +3,7 @@ import { Transferable } from './Message';
import { Opt } from '../new_fields/Doc';
import { Utils, emptyFunction } from '../Utils';
import { DashUploadUtils } from './DashUploadUtils';
+import { Credentials } from 'google-auth-library';
export namespace Database {
@@ -240,21 +241,23 @@ export namespace Database {
}) : slice;
};
- const SanitizedSingletonQuery = async (query: { [key: string]: any }, collection: string, removeId = true) => {
+ const SanitizedSingletonQuery = async <T>(query: { [key: string]: any }, collection: string, removeId = true): Promise<Opt<T>> => {
const results = await SanitizedCappedQuery(query, collection, 1, removeId);
return results.length ? results[0] : undefined;
};
- export const QueryUploadHistory = async (contentSize: number): Promise<Opt<DashUploadUtils.UploadInformation>> => {
- return SanitizedSingletonQuery({ contentSize }, AuxiliaryCollections.GooglePhotosUploadHistory);
+ export const QueryUploadHistory = async (contentSize: number) => {
+ return SanitizedSingletonQuery<DashUploadUtils.UploadInformation>({ contentSize }, AuxiliaryCollections.GooglePhotosUploadHistory);
};
export namespace GoogleAuthenticationToken {
const GoogleAuthentication = "googleAuthentication";
+ export type StoredCredentials = Credentials & { _id: string };
+
export const Fetch = async (userId: string, removeId = true) => {
- return SanitizedSingletonQuery({ userId }, GoogleAuthentication, removeId);
+ return SanitizedSingletonQuery<StoredCredentials>({ userId }, GoogleAuthentication, removeId);
};
export const Write = async (userId: string, token: any) => {