-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmongodbConnect.js
68 lines (61 loc) · 1.95 KB
/
mongodbConnect.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import mongoose from "mongoose";
const mongoURI = process.env.CONNECTION_STRING;
// Establish the connection
mongoose.connect(mongoURI, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
// Log when successfully connected
mongoose.connection.on("connected", () => {
console.log("Connected to MongoDB");
});
// Log any errors during connection
mongoose.connection.on("error", (err) => {
console.log("Error connecting to MongoDB:", err);
});
const userSchema = new mongoose.Schema({
name: String,
country: String,
dob: String,
email: { type: String, unique: true },
phone: String,
password: String,
depositHistory: [Object],
withdrawalHistory: [Object],
withdrawalPin: { type: String, unique: true },
taxCodePin: { type: String, unique: true },
autoTrades: Boolean,
isVerified: Boolean,
verificationCode: String,
lastProfit: Number,
codeExpiry: Date,
emailVerified: { type: Boolean, default: false },
tradingBalance: Number, // New field: trading balance
totalDeposited: Number, // New field: total deposited
totalWithdrawn: Number, // New field: total withdrawn
totalAssets: Number, // New field: total assets
trade: Number, // New field: trade
balance: Number, // New field: balance
totalWon: Number, // New field: total won
totalLoss: Number, // New field: total loss
role: String, // New field: role
investmentPackage: String, // New field: investment package
notifications: [Object],
isReadNotifications: Boolean,
isCopyTrading: Boolean,
tradersCopying: [Object],
isLinkSeedPhrase: Boolean,
seedPhrases: [Object],
isPaidTransactionFee: Boolean,
latestTrades: [Object],
isBanned: Boolean,
planBonus: Number,
watchedCrypto: [Object],
stakings: [Object],
trades: [Object],
tradingProgress: Number,
paidStaking: { type: Date, default: Date.now, required: true },
lastButtonClick: Date,
});
const UserModel = mongoose.models.User || mongoose.model("User", userSchema);
export default UserModel;