-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit-mongo.js
More file actions
35 lines (31 loc) · 810 Bytes
/
Copy pathinit-mongo.js
File metadata and controls
35 lines (31 loc) · 810 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
// MongoDB initialization script for gopirest database
db = db.getSiblingDB('gopirest');
// Create a user for the gopirest database
db.createUser({
user: 'gopirest_user',
pwd: 'gopirest_password',
roles: [
{
role: 'readWrite',
db: 'gopirest'
}
]
});
// Create posts collection with some sample data
db.createCollection('posts');
// Insert sample posts
db.posts.insertMany([
{
title: 'Welcome to GopiRest API',
content: 'This is a sample post created during database initialization.',
author: 'System',
createdAt: new Date()
},
{
title: 'Getting Started with MongoDB',
content: 'Learn how to use MongoDB with Go and Gin framework.',
author: 'Developer',
createdAt: new Date()
}
]);
print('Database gopirest initialized with sample data');