forked from swarooppatilx/scruter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.js
65 lines (59 loc) · 1.74 KB
/
database.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
const mongoose = require('mongoose');
const bcrypt = require('bcrypt');
// Connect to MongoDB
mongoose
.connect(process.env.DB_URL)
.then(() => console.log('Connected to MongoDB'))
.catch(error => console.error('Error connecting to MongoDB:', error));
// Define the User schema
const userSchema = new mongoose.Schema({
username: { type: String, required: true, unique: true },
email: { type: String, required: true, unique: true },
phone: { type: String, required: true, unique: true },
password: { type: String, required: true },
});
// Define the Food schema
const foodSchema = new mongoose.Schema({
title: String,
image: String,
location: String,
latitude: String,
longitude: String,
description: String,
username: { type: String, required: true },
email: { type: String, required: true },
phone: { type: String, required: true },
});
// Define the House schema
const houseSchema = new mongoose.Schema({
title: String,
image: String,
location: String,
rent: Number,
latitude: String,
longitude: String,
description: String,
username: { type: String, required: true },
email: { type: String, required: true },
phone: { type: String, required: true },
});
// Define the Market schema
const marketSchema = new mongoose.Schema({
title: String,
image: String,
location: String,
price: Number,
latitude: String,
longitude: String,
description: String,
username: { type: String, required: true },
email: { type: String, required: true },
phone: { type: String, required: true },
});
// Export the models
module.exports = {
User: mongoose.model('User', userSchema),
Food: mongoose.model('Food', foodSchema),
House: mongoose.model('House', houseSchema),
Market: mongoose.model('Market', marketSchema),
};