57 lines
1.1 KiB
Plaintext
57 lines
1.1 KiB
Plaintext
use budgetdb
|
|
|
|
db.createCollection(“users”)
|
|
db.createCollection(“accounts”)
|
|
db.createCollection("budgets")
|
|
db.createCollection("budgetPeriods")
|
|
|
|
users: [{
|
|
_id: <id>
|
|
username: "jules"
|
|
}]
|
|
|
|
accounts: [{
|
|
name: amazon,
|
|
user: <id>
|
|
}]
|
|
|
|
budgets: [{
|
|
name: "main"
|
|
}]
|
|
|
|
budgetPeriods: [{
|
|
user: ObjectId("63faac6823cd0682fe8c8ed6"),
|
|
startDate: new Date("2023-03-03"),
|
|
endDate: new Date("2023-03-10"),
|
|
leftover: 23.22,
|
|
cashflows: [
|
|
{
|
|
account: ObjectId("63fab01a23cd0682fe8c8ed7"),
|
|
dueDate: new Date("2023-03-04"),
|
|
postingDate: new Date("2023-03-04"),
|
|
amount: 22.23,
|
|
isIncome: false
|
|
}
|
|
],
|
|
verified: true,
|
|
adhocPurchases: [
|
|
{
|
|
postingDate: new Date("2023-03-05"),
|
|
amount: 1.99,
|
|
description: "",
|
|
isIncome: false
|
|
}
|
|
]
|
|
}]
|
|
|
|
$push operator for adding to arrays
|
|
|
|
2023-03-07
|
|
|
|
{
|
|
user: ObjectId("63faac6823cd0682fe8c8ed6"),
|
|
start: { $lte: "2023-03-07T05:00:00.000Z" },
|
|
end: { $gt: "2023-03-07T05:00:00.000Z" }
|
|
}
|
|
|
|
http://localhost:3001/jules/period/in/2023-03-01..2023-04-01 |