-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractice Code
More file actions
170 lines (168 loc) · 3.42 KB
/
Copy pathPractice Code
File metadata and controls
170 lines (168 loc) · 3.42 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
test> show dbs
Practice 72.00 KiB
admin 40.00 KiB
config 72.00 KiB
local 40.00 KiB
test> use Practice
switched to db Practice
Practice> db
Practice
Practice> use new1
switched to db new1
new1> db
new1
new1> db.dropnew1
new1.dropnew1
new1> show dbs
Practice 72.00 KiB
admin 40.00 KiB
config 72.00 KiB
local 40.00 KiB
new1> use Practice
switched to db Practice
Practice> db
Practice
Practice> show collections
Trial
Practice> db.createCollection('hello')
{ ok: 1 }
Practice> show collections
hello
Trial
Practice> db.hello.drop()
TypeError: db.hello.drop is not a function
Practice> chow collections
Uncaught:
SyntaxError: Missing semicolon. (1:4)
> 1 | chow collections
| ^
2 |
Practice> show collections
hello
Trial
Practice> db.hello.drop()
TypeError: db.hello.drop is not a function
Practice> db.hello.drop();
TypeError: db.hello.drop is not a function
Practice> db.drop(hello)
ReferenceError: hello is not defined
Practice> db.drop('hello')
TypeError: db.drop is not a function
Practice> show collections
hello
Trial
Practice> db.collection.drop('hello')
true
Practice> show collections
hello
Trial
Practice> db.Trial.find()
[
{
_id: ObjectId('65abc801d0e7bfa5a0c0027a'),
title: 'My first post',
content: 'This is the content of my first post'
},
{
_id: ObjectId('65abc877d0e7bfa5a0c0027b'),
title: 'My second post',
content: 'This is my secont post'
},
{
_id: ObjectId('65abd0772adbaa9d8b81f2b8'),
name: 'Aksh',
surname: 'Raizada',
email: 'aksh.raizada2021@vitbhopal.ac.in'
},
{
_id: ObjectId('65abd2262adbaa9d8b81f2b9'),
name: 'Prakhar',
surname: 'Vaish',
grade: 'A'
},
{
_id: ObjectId('65abd2262adbaa9d8b81f2ba'),
name: 'Aalaap',
surname: 'Ghanekar',
grade: 'B'
},
{
_id: ObjectId('65abd2262adbaa9d8b81f2bb'),
name: 'Mudit',
surname: 'Shrivastav',
grade: 'C'
},
{
_id: ObjectId('65abd3ce2adbaa9d8b81f2bc'),
brand: 'Jeep',
model: 'Wrangler',
date: ISODate('2024-01-20T14:08:14.524Z')
}
]
Practice> db.Trial.find({grade: 'A'})
[
{
_id: ObjectId('65abd2262adbaa9d8b81f2b9'),
name: 'Prakhar',
surname: 'Vaish',
grade: 'A'
}
]
Practice> db.comments.insert({
... 'name': 'Harry',
... 'lang': 'JavaScript',
... 'member_since': 5
... })
DeprecationWarning: Collection.insert() is deprecated. Use insertOne, insertMany, or bulkWrite.
{
acknowledged: true,
insertedIds: { '0': ObjectId('65aca2022d2b770ddf474fa5') }
}
Practice> db.Trial.find()
[
{
_id: ObjectId('65abc801d0e7bfa5a0c0027a'),
title: 'My first post',
content: 'This is the content of my first post'
},
{
_id: ObjectId('65abc877d0e7bfa5a0c0027b'),
title: 'My second post',
content: 'This is my secont post'
},
{
_id: ObjectId('65abd0772adbaa9d8b81f2b8'),
name: 'Aksh',
surname: 'Raizada',
email: 'aksh.raizada2021@vitbhopal.ac.in'
},
{
_id: ObjectId('65abd2262adbaa9d8b81f2b9'),
name: 'Prakhar',
surname: 'Vaish',
grade: 'A'
},
{
_id: ObjectId('65abd2262adbaa9d8b81f2ba'),
name: 'Aalaap',
surname: 'Ghanekar',
grade: 'B'
},
{
_id: ObjectId('65abd2262adbaa9d8b81f2bb'),
name: 'Mudit',
surname: 'Shrivastav',
grade: 'C'
},
{
_id: ObjectId('65abd3ce2adbaa9d8b81f2bc'),
brand: 'Jeep',
model: 'Wrangler',
date: ISODate('2024-01-20T14:08:14.524Z')
}
]
Practice> show collections
comments
hello
Trial
Practice>