Skip to content

Commit

Permalink
ref to campaign instead of string in votes
Browse files Browse the repository at this point in the history
  • Loading branch information
hgwood committed Jul 30, 2018
1 parent f40abb2 commit 1fd94c9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions functions/src/cast-vote.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as admin from "firebase-admin";
import { firestore } from "firebase-admin";
import * as functions from "firebase-functions";
import { Config, isEnabled, asNumber, asBoolean } from "./config";
import { selectCampaign } from "./select-campaign";

const db = admin.firestore();
const db = firestore();
const config = functions.config() as Config;
const requireUniqueVote = asBoolean(
config.features.voting_campaigns.require_unique_vote
Expand All @@ -18,8 +18,8 @@ interface RequestPayload {
export interface Vote {
value: string;
voter: string;
campaign: string;
recordedAt: admin.firestore.Timestamp;
campaign: firestore.DocumentReference;
recordedAt: firestore.Timestamp;
}

export const castVote = functions.https.onCall(
Expand Down Expand Up @@ -52,8 +52,8 @@ export const castVote = functions.https.onCall(
.substr(0, 7);

const vote: Vote = {
campaign: campaignId,
recordedAt: admin.firestore.Timestamp.fromDate(voteDate),
campaign: db.collection("voting-campaign").doc(campaignId),
recordedAt: firestore.Timestamp.fromDate(voteDate),
voter: payload.voter,
value: payload.vote
};
Expand Down

0 comments on commit 1fd94c9

Please sign in to comment.