forked from Deen-Bridge/dnb-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLedgerEntry.js
More file actions
40 lines (37 loc) · 914 Bytes
/
Copy pathLedgerEntry.js
File metadata and controls
40 lines (37 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// models/LedgerEntry.js
import mongoose from "mongoose";
const ledgerEntrySchema = new mongoose.Schema(
{
educator: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
required: true,
index: true,
},
type: {
type: String,
enum: ["sale", "payout"],
required: true,
},
txRef: {
type: String,
required: true,
index: true,
},
amount: {
type: String, // String representation of USDC decimal amount
required: true,
},
amountStroops: {
type: String, // String representation of stroops (BigInt)
required: true,
},
settlement: {
type: String,
enum: ["direct", "platform_collect"],
},
},
{ timestamps: { createdAt: true, updatedAt: false } }
);
ledgerEntrySchema.index({ educator: 1, createdAt: -1 });
export default mongoose.model("LedgerEntry", ledgerEntrySchema);