Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private query(): Promise {
const firestore: firebase.firestore.Firestore = firebase.firestore();
if (this.nextQueryAfter) {
return firestore.collection('decks')
.where('meta.feed', '==', true)
.orderBy('meta.published_at', 'desc')
.startAfter(this.nextQueryAfter)
.limit(this.queryLimit).get();
} else {
return firestore.collection('decks')
.where('meta.feed', '==', true)
.orderBy('meta.published_at', 'desc')
.limit(this.queryLimit).get();
}
}
getCollection(name: CollectionName): CollectionReference {
return firebase.firestore().collection(name)
}
return new Promise(async (resolve, reject) => {
const firestore: firebase.firestore.Firestore = firebase.firestore();
const now: firebase.firestore.Timestamp = firebase.firestore.Timestamp.now();
user.data.updated_at = now;
try {
await firestore.collection('users').doc(user.id).set(user.data, {merge: true});
resolve(user);
} catch (err) {
reject(err);
}
});
}
return new Promise(async (resolve, reject) => {
const firestore: firebase.firestore.Firestore = firebase.firestore();
try {
const snapshot: firebase.firestore.DocumentSnapshot = await firestore.collection('decks').doc(deckId).get();
if (!snapshot.exists) {
reject('Deck not found');
return;
}
const deck: DeckData = snapshot.data() as DeckData;
resolve({
id: snapshot.id,
data: deck
});
} catch (err) {
return new Promise(async (resolve, reject) => {
const firestore: firebase.firestore.Firestore = firebase.firestore();
try {
const snapshot: firebase.firestore.DocumentSnapshot = await firestore.collection(`/decks/${deckId}/slides`).doc(slideId).get();
if (!snapshot.exists) {
reject('Slide not found');
return;
}
const slide: SlideData = snapshot.data() as SlideData;
resolve({
id: snapshot.id,
data: slide
});
} catch (err) {