forked from Prompt-Hash-Stellar/prompt-hash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVote.ts
More file actions
28 lines (25 loc) · 603 Bytes
/
Copy pathVote.ts
File metadata and controls
28 lines (25 loc) · 603 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import mongoose from "mongoose";
/**
* Vote model — Issue #113
* One upvote per wallet per prompt (enforced by unique index).
*/
const voteSchema = new mongoose.Schema(
{
promptId: {
type: String,
required: true,
index: true,
},
voterWallet: {
type: String,
required: true,
lowercase: true,
index: true,
},
},
{ timestamps: true }
);
// One vote per wallet per prompt
voteSchema.index({ promptId: 1, voterWallet: 1 }, { unique: true });
const Vote = mongoose.models.Vote || mongoose.model("Vote", voteSchema);
export default Vote;