Fix issue #72: Link actor with a discord user
All checks were successful
Test / test (push) Successful in 2s
All checks were successful
Test / test (push) Successful in 2s
This commit is contained in:
@@ -54,6 +54,10 @@ const ActorSchema = new Schema({
|
||||
default: null
|
||||
},
|
||||
foundryActorId: { type: String },
|
||||
// The Discord player this character belongs to (Syndria98/dragonroll#72): each player
|
||||
// of the server a campaign is linked to holds one character of it. Only
|
||||
// routes/discord.js writes it, so the campaign keeps owning it whichever guild claimed it.
|
||||
discordUserId: { type: String, default: null },
|
||||
date: { type: Date, default: Date.now }
|
||||
});
|
||||
|
||||
@@ -62,4 +66,10 @@ ActorSchema.index(
|
||||
{ unique: true, partialFilterExpression: { foundryActorId: { $type: 'string' } } }
|
||||
);
|
||||
|
||||
// A player holds at most one character of a campaign: the id is unique within it.
|
||||
ActorSchema.index(
|
||||
{ campaign: 1, discordUserId: 1 },
|
||||
{ unique: true, partialFilterExpression: { discordUserId: { $type: 'string' } } }
|
||||
);
|
||||
|
||||
module.exports = mongoose.model('Actor', ActorSchema);
|
||||
|
||||
Reference in New Issue
Block a user