Update models.js
Browse files
models.js
CHANGED
@@ -1,4 +1,7 @@
|
|
1 |
import mongoose from "mongoose";
|
|
|
|
|
|
|
2 |
|
3 |
const apiKeySchema = new mongoose.Schema({
|
4 |
key: { type: String, unique: true, required: true },
|
@@ -11,6 +14,13 @@ const apiKeySchema = new mongoose.Schema({
|
|
11 |
email: { type: String, default: null }
|
12 |
}, { collection: "ApiKey" });
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
const jobSchema = new mongoose.Schema({
|
16 |
job_id: { type: String, unique: true },
|
@@ -19,6 +29,7 @@ const jobSchema = new mongoose.Schema({
|
|
19 |
createdAt: { type: Date, default: Date.now, expires: 300 }
|
20 |
});
|
21 |
|
|
|
22 |
export const Job = mongoose.model("Job", jobSchema);
|
23 |
export const ApiKey = mongoose.model("ApiKey", apiKeySchema);
|
24 |
|
|
|
1 |
import mongoose from "mongoose";
|
2 |
+
import * as uuid from 'uuid';
|
3 |
+
|
4 |
+
const feduiid = uuid.v4();
|
5 |
|
6 |
const apiKeySchema = new mongoose.Schema({
|
7 |
key: { type: String, unique: true, required: true },
|
|
|
14 |
email: { type: String, default: null }
|
15 |
}, { collection: "ApiKey" });
|
16 |
|
17 |
+
const federationSchema = new mongoose.Schema({
|
18 |
+
uuid: { type: String, default: feduiid, unique: true },
|
19 |
+
name: { type: String, required: true, unique: true },
|
20 |
+
owner: { type: Number, required: true },
|
21 |
+
banned_users: [{ type: Number }],
|
22 |
+
sub_federations: [{ type: String }]
|
23 |
+
});
|
24 |
|
25 |
const jobSchema = new mongoose.Schema({
|
26 |
job_id: { type: String, unique: true },
|
|
|
29 |
createdAt: { type: Date, default: Date.now, expires: 300 }
|
30 |
});
|
31 |
|
32 |
+
export const Federation = mongoose.model("Federation", federationSchema);
|
33 |
export const Job = mongoose.model("Job", jobSchema);
|
34 |
export const ApiKey = mongoose.model("ApiKey", apiKeySchema);
|
35 |
|