Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
23 lines
705 B
JavaScript
23 lines
705 B
JavaScript
import mongoose from 'mongoose';
|
|
import { generateId } from '../../utils.js';
|
|
const { Schema } = mongoose;
|
|
|
|
const appPasswordSchema = new mongoose.Schema(
|
|
{
|
|
_reference: { type: String, default: () => generateId()() },
|
|
name: { type: String, required: true },
|
|
user: { type: Schema.Types.ObjectId, ref: 'user', required: true },
|
|
active: { type: Boolean, required: true, default: true },
|
|
secret: { type: String, required: true, select: false },
|
|
},
|
|
{ timestamps: true }
|
|
);
|
|
|
|
appPasswordSchema.virtual('id').get(function () {
|
|
return this._id;
|
|
});
|
|
|
|
appPasswordSchema.set('toJSON', { virtuals: true });
|
|
|
|
export const appPasswordModel = mongoose.model('appPassword', appPasswordSchema);
|