Skip to content

Commit dc9b780

Browse files
committed
initial backend implementation with MongoDB and scenario CRUD operations
1 parent 424bfb4 commit dc9b780

8 files changed

Lines changed: 2271 additions & 21 deletions

File tree

app/(Minitool_one)/minitool_1.jsx

Lines changed: 360 additions & 9 deletions
Large diffs are not rendered by default.

backend/models/Scenario.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const mongoose = require("mongoose");
2+
3+
const batteryItemSchema = new mongoose.Schema({
4+
brand: {
5+
type: String,
6+
enum: ["Tough Cell", "Always Ready"],
7+
required: true,
8+
},
9+
lifespan: {
10+
type: Number,
11+
required: true,
12+
min: 1,
13+
max: 130,
14+
},
15+
visible: {
16+
type: Boolean,
17+
default: true,
18+
},
19+
});
20+
21+
const scenarioSchema = new mongoose.Schema(
22+
{
23+
name: {
24+
type: String,
25+
required: true,
26+
trim: true,
27+
},
28+
description: {
29+
type: String,
30+
default: "",
31+
},
32+
data: [batteryItemSchema],
33+
minLifespan: {
34+
type: Number,
35+
default: null,
36+
},
37+
maxLifespan: {
38+
type: Number,
39+
default: null,
40+
},
41+
},
42+
{
43+
timestamps: true,
44+
},
45+
);
46+
47+
module.exports = mongoose.model("Scenario", scenarioSchema);

0 commit comments

Comments
 (0)