@wepublish/api
Version:
API core for we.publish.
39 lines • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.userPollVote = exports.getPoll = void 0;
const tslib_1 = require("tslib");
const getPoll = (id, poll) => {
return poll.findUnique({
where: { id },
include: {
answers: {
include: {
_count: true
},
orderBy: {
createdAt: 'asc'
}
},
externalVoteSources: {
include: {
voteAmounts: true
}
}
}
});
};
exports.getPoll = getPoll;
const userPollVote = (pollId, authenticateUser, pollVote) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const { user } = authenticateUser();
const vote = yield pollVote.findUnique({
where: {
pollId_userId: {
pollId,
userId: user.id
}
}
});
return vote === null || vote === void 0 ? void 0 : vote.answerId;
});
exports.userPollVote = userPollVote;
//# sourceMappingURL=poll.public-queries.js.map