This repository has been archived on 2025-12-25. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2023-05-09 16:23:45 +02:00

35 lines
671 B
JavaScript

const mongoose = require('mongoose');
const crypto = require("crypto");
const schema = new mongoose.Schema({
user: {
type: mongoose.Types.ObjectId, ref: 'User'
},
description: {
type: String
},
created: {
type: Date,
default: Date.now,
index : true
},
updated: {
type: Date,
default: Date.now
},
isActive: {
type: Boolean,
default: true
},
apiKey: {
type: String,
default: function() {
return crypto.randomBytes(64).toString('hex');
},
index: true
}
});
module.exports = mongoose.model('ApiKey', schema)