-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostSender.js
120 lines (114 loc) · 4.37 KB
/
postSender.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
const Post = require("./server/models/Post");
// Post 1
async function insertAgriculturePosts() {
try {
await Post.insertMany([
{
title: "Sustainable Farming Practices",
body: "Explore sustainable farming practices that help preserve soil health and biodiversity.",
featureImg: "/img/1.jpg", // Use 1.jpg as feature image
requiredImg: "/img/2.jpg", // Use 2.jpg as required image
optionalImg: "/img/3.jpg", // Use 3.jpg as optional image (if needed)
},
{
title: "Organic Farming Benefits and Challenges",
body: "Understand the benefits and challenges of organic farming, focusing on pesticide-free practices.",
featureImg: "/img/4.jpg",
requiredImg: "/img/2.jpg",
// OptionalImg is skipped intentionally for testing
},
// Add more posts as needed
]);
console.log("Agriculture posts inserted successfully.");
} catch (error) {
console.error("Error inserting agriculture posts:", error);
}
}
// Post 2
async function insertHealthPosts() {
try {
const createdAt = new Date("2023-07-03T00:00:00Z"); // Set created date to July 3rd, 2023, a past date
const updatedAt = new Date(); // Current date and time
await Post.insertMany([
{
title: "Healthy Eating Habits",
body: "Learn about healthy eating habits and their impact on overall well-being.",
featureImg: "/img/1.jpg",
requiredImg: "/img/2.jpg",
optionalImg: "/img/3.jpg",
createdAt: createdAt,
updatedAt: updatedAt,
},
{
title: "Exercise and Fitness Tips",
body: "Explore effective exercise routines and fitness tips for maintaining a healthy lifestyle.",
featureImg: "/img/1.jpg",
requiredImg: "/img/4.jpg",
// OptionalImg is skipped intentionally for testing
createdAt: createdAt,
updatedAt: updatedAt,
},
// Add more posts as needed
]);
console.log("Health posts inserted successfully.");
} catch (error) {
console.error("Error inserting health posts:", error);
}
}
//* ----------------- You can use this pattern, then change schema model if you like this------------------*//
// Post 3
async function insertTechPosts() {
try {
const insertedPosts = await Post.insertMany([
{
title: "Building APIs with Node.js",
body: "Learn how to use Node.js to build RESTful APIs using frameworks like Express.js",
},
{
title: "Deployment of Node.js applications",
body: "Understand the different ways to deploy your Node.js applications, including on-premises, cloud, and container environments...",
},
{
title: "Authentication and Authorization in Node.js",
body: "Learn how to add authentication and authorization to your Node.js web applications using Passport.js or other authentication libraries.",
},
{
title: "Understand how to work with MongoDB and Mongoose",
body: "Understand how to work with MongoDB and Mongoose, an Object Data Modeling (ODM) library, in Node.js applications.",
},
{
title: "build real-time, event-driven applications in Node.js",
body: "Socket.io: Learn how to use Socket.io to build real-time, event-driven applications in Node.js.",
},
{
title: "Discover how to use Express.js",
body: "Discover how to use Express.js, a popular Node.js web framework, to build web applications.",
},
{
title: "Asynchronous Programming with Node.js",
body: "Asynchronous Programming with Node.js: Jedidiah - Explore the asynchronous nature of Node.js and how it allows for non-blocking I/O operations.",
},
{
title: "Learn the basics of Node.js and its architecture",
body: "Learn the basics of Node.js and its architecture, how it works, and why it is popular among developers.",
},
{
title: "NodeJs Limiting Network Traffic by Jedidiah",
body: "Learn how to limit network traffic.",
},
{
title: "Learn Morgan - HTTP Request logger for NodeJs",
body: "Learn Morgan.",
},
]);
console.log("Tech posts inserted successfully:");
} catch (error) {
console.error("Error inserting tech posts:", error);
}
}
// Add more Posts
module.exports = {
insertAgriculturePosts,
insertTechPosts,
insertHealthPosts,
};