Skip to content

Commit

Permalink
Create Credential.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Nov 22, 2024
1 parent 80b6d87 commit 90629c3
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions blockchain_integration/pi_network/models/Credential.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const mongoose = require('mongoose');

const credentialSchema = new mongoose.Schema({
userId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User ',
required: true,
},
credentialType: {
type: String,
required: true,
},
credentialData: {
type: Object,
required: true,
},
issuedAt: {
type: Date,
default: Date.now,
},
expiresAt: {
type: Date,
},
status: {
type: String,
enum: ['active', 'revoked'],
default: 'active',
},
});

// Method to revoke a credential
credentialSchema.methods.revoke = function () {
this.status = 'revoked';
return this.save();
};

const Credential = mongoose.model('Credential', credentialSchema);
module.exports = Credential;

0 comments on commit 90629c3

Please sign in to comment.