{"id":662,"date":"2021-09-30T00:57:41","date_gmt":"2021-09-30T00:57:41","guid":{"rendered":"https:\/\/scrutineer.co.kr\/wordpress\/?p=662"},"modified":"2021-10-21T22:44:46","modified_gmt":"2021-10-21T22:44:46","slug":"%eb%aa%bd%ea%b3%a0%eb%94%94%eb%b9%84-%ec%9d%b8-%ec%95%a1%ec%85%98-2%ec%9e%a5","status":"publish","type":"post","link":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/2021\/09\/30\/%eb%aa%bd%ea%b3%a0%eb%94%94%eb%b9%84-%ec%9d%b8-%ec%95%a1%ec%85%98-2%ec%9e%a5\/","title":{"rendered":"\ubabd\uace0\ub514\ube44 \uc778 \uc561\uc158 2\uc7a5"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\" style=\"font-size:30px\">\uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8 \uc178\uc744 \ud1b5\ud55c MongoDB<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\ub2e4\ub978 \ud234\uacfc \ub2e4\ub978 \uc810\uc740 \ucffc\ub9ac \uc5b8\uc5b4\uc5d0 \uc788\ub2e4. SQL\uacfc \uac19\uc774 \ud45c\uc900\ud654\ub41c \ucffc\ub9ac \uc5b8\uc5b4\ub97c \uc0ac\uc6a9\ud558\ub294 \uac83 \ub300\uc2e0\uc5d0 \uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8 \ud504\ub85c\uadf8\ub798\ubc0d \uc5b8\uc5b4\uc640 \uac04\ub2e8\ud55c API\ub97c \uc0ac\uc6a9\ud574 \uc11c\ubc84\uc640 \uc5f0\uacb0\ud55c\ub2e4.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">MongoDB\uc124\uce58(\ubd80\ub85dA)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uc708\ub3c4\uc6b0 \uc124\uce58<\/p>\n\n\n\n<figure class=\"wp-block-embed\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/www.mongodb.com\/try\/download\/community\n<\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\uc6d0\ub3c4\uc6b0 \uba85\ub839\ud504\ub86c\ud504\ud2b8(\ucee4\ub9e8\ub4dc\ucc3d)\uc5d0\uc11c\ub3c4 \uba85\ub839\uc5b4\ub85c \uc811\uc18d\uc774 \uac00\ub2a5\ud558\ub3c4\ub85d Path\ub97c \uc124\uc815<br>\uc81c\uc5b4\ud310 &gt; \ud658\uacbd\ubcc0\uc218 &gt; \uc2dc\uc2a4\ud15cPath &gt; \ubabd\uace0\ub514\ube44\uc124\uce58 bin\uacbd\ub85c \ucd94\uac00 (C:\\Program Files\\MongoDB\\Server\\5.0\\bin)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&gt;mongo\nMongoDB shell version v5.0.3\nconnecting to: mongodb:\/\/127.0.0.1:27017\/?compressors=disabled&amp;gssapiServiceName=mongodb\nImplicit session: session { \"id\" : UUID(\"ac3b57dd-3cfb-4e30-8bf1-e670a291f133\") }\nMongoDB server version: 5.0.3\n================\nWarning: the \"mongo\" shell has been superseded by \"mongosh\",\nwhich delivers improved usability and compatibility.The \"mongo\" shell has been deprecated and will be removed in\nan upcoming release.\nWe recommend you begin using \"mongosh\".\nFor installation instructions, see\nhttps:\/\/docs.mongodb.com\/mongodb-shell\/install\/\n================\nWelcome to the MongoDB shell.\n...\n&gt; use testdb\nswitched to db testdb<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">\ub370\uc774\ud130\ubca0\uc774\uc2a4, \uceec\ub809\uc158, \ub3c4\ud050\uba3c\ud2b8<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">MongoDB\uac00 RDBMS\uc758 \ud14c\uc774\ube14\uacfc \uac19\uc774 \ub3c4\ud050\uba3c\ud2b8\ub4e4\uc744 grouping\ud558\ub294 \uac83\uc744 \uceec\ub809\uc158(collection)\uc774\ub77c \ubd80\ub978\ub2e4.<br>=&gt; \uc0ac\uc6a9\uc790(user) \/ \uc8fc\ubb38(order)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">MongoDB\ub294 \uceec\ub809\uc158\ub4e4\uc744 \ubcc4\ub3c4\uc758 \ub370\uc774\ud130\ubca0\uc774\uc2a4(\ub2e8\uc9c0 \uceec\ub809\uc158\uc744 \ubd84\ub9ac\ud558\ub294 \ub124\uc784\uc2a4\ud398\uc774\uc2a4\uac1c\ub150)\uc5d0 \ubd84\ub9ac\ud55c\ub2e4. \ub530\ub77c\uc11c \uc9c8\uc758\ub97c \ud558\uae30 \uc6d0\ud558\ub294 \ub300\uc0c1 \ub3c4\ud050\uba3c\ud2b8\uac00 \uc874\uc7ac\ud558\ub294 \ub370\uc774\ud130\ubca0\uc774\uc2a4\uc640 \uceec\ub809\uc158\uc744 \uc54c\uc544\uc57c\ud55c\ub2e4.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\ub370\uc774\ud130\ubca0\uc774\uc2a4\ubcc0\uacbd (\uc544\uc9c1 \uc2e4\uc81c\ub85c \uc0dd\uc131\uc548\ub41c\uc0c1\ud0dc. \ub370\uc774\ud130\ubca0\uc774\uc2a4\uc640 \uceec\ub809\uc158\uc740 \ub3c4\ud050\uba3c\ud2b8\uac00 \ucc98\uc74c \uc785\ub825\ub420 \ub54c \uc0dd\uc131\ub428)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&gt; use tutorial\nswitched to db tutorial<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">MongoDB\uac00 \ub370\uc774\ud130\ubca0\uc774\uc2a4\uc640 \uceec\ub809\uc158\uc744 \ubaa8\ub450 \uac00\uc9c0\uace0 \uc788\ub294 \uc774\uc720 : \ub370\uc774\ud130\ubca0\uc774\uc2a4\uc758 \ubaa8\ub4e0 \uceec\ub809\uc158\uc740 \uac19\uc740 \ud30c\uc77c\uc5d0 grouping\ud568. \uba54\ubaa8\ub9ac \uad00\uc810 \ubc0f \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc5d0\uc11c \uc811\uadfc\ud560 \ub54c \uc774\uc810<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">\uc0bd\uc785\uacfc \uc9c8\uc758<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&gt; db.users.insert({username:\"una\"})\nWriteResult({ \"nInserted\" : 1 })\n&gt; db.users.find()\n{ \"_id\" : ObjectId(\"6154f18d7b36c03e7fbbab05\"), \"username\" : \"una\" }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">_id : \ub3c4\ud050\uba3c\ud2b8\uc758 \ud504\ub77c\uc774\uba38\ub9ac \ud0a4 (\uc0bd\uc785\uc744 \ud1b5\ud574 _id\ub97c \uc9c0\uc815\ud560 \uc218 \uc788\uc73c\uba70, \uc5c6\uc744 \ub54c \uc790\ub3d9 \uc0dd\uc131)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&gt; db.users.insert({username:\"gongu\"})\nWriteResult({ \"nInserted\" : 1 })\n&gt; db.users.count()\n2<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">count : \uceec\ub809\uc158 \uc218 counting<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&gt; db.users.insert({username:\"una\"})\nWriteResult({ \"nInserted\" : 1 })\n&gt; db.users.find()\n{ \"_id\" : ObjectId(\"6154f18d7b36c03e7fbbab05\"), \"username\" : \"una\" }\n{ \"_id\" : ObjectId(\"6154f37b7b36c03e7fbbab06\"), \"username\" : \"gongu\" }\n{ \"_id\" : ObjectId(\"6154f4c67b36c03e7fbbab07\"), \"username\" : \"una\" }\n&gt; db.users.find({$and:[\n... {_id:ObjectId(\"6154f18d7b36c03e7fbbab05\")},\n... {username:\"una\"}\n... ]})\n{ \"_id\" : ObjectId(\"6154f18d7b36c03e7fbbab05\"), \"username\" : \"una\" }\n&gt; db.users.find({$or:[\n... {username:\"una\"},\n... {username:\"gongu\"}\n... ]})\n{ \"_id\" : ObjectId(\"6154f18d7b36c03e7fbbab05\"), \"username\" : \"una\" }\n{ \"_id\" : ObjectId(\"6154f37b7b36c03e7fbbab06\"), \"username\" : \"gongu\" }\n{ \"_id\" : ObjectId(\"6154f4c67b36c03e7fbbab07\"), \"username\" : \"una\" }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">$and : AND \uc5f0\uc0b0\uc790<br>$or : OR \uc5f0\uc0b0\uc790<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">\ub3c4\ud050\uba3c\ud2b8 \uc5c5\ub370\uc774\ud2b8<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&gt; db.users.update({username:\"gongu\"},{$set:{country:\"Korea\"}})\nWriteResult({ \"nMatched\" : 1, \"nUpserted\" : 0, \"nModified\" : 1 })\n&gt; db.users.find(\n... {username:\"gongu\"})\n{ \"_id\" : ObjectId(\"6154f37b7b36c03e7fbbab06\"), \"username\" : \"gongu\", \"country\" : \"Korea\" }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">$set : \ub3c4\ud050\uba3c\ud2b8\ub97c \ucc3e\uc544\uc11c \uc18d\uc131\uc744 \ucd94\uac00\uc218\uc815<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&gt; db.users.update({username:\"una\"},{country:\"japan\"})\nWriteResult({ \"nMatched\" : 1, \"nUpserted\" : 0, \"nModified\" : 1 })\n&gt; db.users.find()\n{ \"_id\" : ObjectId(\"6154f18d7b36c03e7fbbab05\"), \"country\" : \"japan\" }\n{ \"_id\" : ObjectId(\"6154f37b7b36c03e7fbbab06\"), \"username\" : \"gongu\", \"country\" : \"Korea\" }\n{ \"_id\" : ObjectId(\"6154f4c67b36c03e7fbbab07\"), \"username\" : \"una\" }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\ud544\ub4dc\ub97c \ucd94\uac00\ud558\uac70\ub098 \uac12\uc744 \uc124\uc815\ud558\uae30\ub97c \uc6d0\ud55c\ub2e4\uba74 \ubc18\ub4dc\uc2dc $set\uc744 \uc0ac\uc6a9.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&gt; db.users.update({username:\"gongu\"},{$unset:{country:2}})\nWriteResult({ \"nMatched\" : 1, \"nUpserted\" : 0, \"nModified\" : 1 })\n&gt; db.users.find()\n{ \"_id\" : ObjectId(\"6154f18d7b36c03e7fbbab05\"), \"country\" : \"japan\" }\n{ \"_id\" : ObjectId(\"6154f37b7b36c03e7fbbab06\"), \"username\" : \"gongu\" }\n{ \"_id\" : ObjectId(\"6154f4c67b36c03e7fbbab07\"), \"username\" : \"una\" }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">$unset : \uc18d\uc131\uc744 \uc0ad\uc81c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&gt; var movies = [\"m1\",\"m2\",\"m3\"]\n&gt; var hobby = [\"h1\", \"h2\", \"h3\"]\n&gt; var favoriteObj = {favorites:{movies:movies, hobby:hobby}}\n&gt; favoriteObj\n{\n        \"favorites\" : {\n                \"movies\" : [\n                        \"m1\",\n                        \"m2\",\n                        \"m3\"\n                ],\n                \"hobby\" : [\n                        \"h1\",\n                        \"h2\",\n                        \"h3\"\n                ]\n        }\n}\n&gt; db.users.update({username:\"gongu\"},{$set:favoriteObj})\nWriteResult({ \"nMatched\" : 1, \"nUpserted\" : 0, \"nModified\" : 1 })\n&gt; db.users.find()\n{ \"_id\" : ObjectId(\"6154f18d7b36c03e7fbbab05\"), \"country\" : \"japan\" }\n{ \"_id\" : ObjectId(\"6154f37b7b36c03e7fbbab06\"), \"username\" : \"gongu\", \"favorites\" : { \"movies\" : [ \"m1\", \"m2\", \"m3\" ], \"hobby\" : [ \"h1\", \"h2\", \"h3\" ] } }\n{ \"_id\" : ObjectId(\"6154f4c67b36c03e7fbbab07\"), \"username\" : \"una\" }\n&gt; db.users.find().pretty()\n{ \"_id\" : ObjectId(\"6154f18d7b36c03e7fbbab05\"), \"country\" : \"japan\" }\n{\n        \"_id\" : ObjectId(\"6154f37b7b36c03e7fbbab06\"),\n        \"username\" : \"gongu\",\n        \"favorites\" : {\n                \"movies\" : [\n                        \"m1\",\n                        \"m2\",\n                        \"m3\"\n                ],\n                \"hobby\" : [\n                        \"h1\",\n                        \"h2\",\n                        \"h3\"\n                ]\n        }\n}\n{ \"_id\" : ObjectId(\"6154f4c67b36c03e7fbbab07\"), \"username\" : \"una\" }\n&gt; db.users.find({\"favorites.movies\":\"m2\"})\n{ \"_id\" : ObjectId(\"6154f37b7b36c03e7fbbab06\"), \"username\" : \"gongu\", \"favorites\" : { \"movies\" : [ \"m1\", \"m2\", \"m3\" ], \"hobby\" : [ \"h1\", \"h2\", \"h3\" ] } }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\ub3c4\ud050\uba3c\ud2b8\uc548\uc758 \uc624\ube0c\uc81d\ud2b8(favorites) \ud0a4(hobby)\uc5d0 \uc811\uadfc\ud558\uae30 \uc704\ud574\uc120 \ub2f7(.)\uc744 \uc774\uc6a9\ud558\uc5ec \uc811\uadfc\ud55c\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&gt; db.users.update({username:\"gongu\"},{$set:{\"favorites.movies\":[\"mv1\"]}})\nWriteResult({ \"nMatched\" : 1, \"nUpserted\" : 0, \"nModified\" : 1 })\n&gt; db.users.find().pretty()\n{ \"_id\" : ObjectId(\"6154f18d7b36c03e7fbbab05\"), \"country\" : \"japan\" }\n{\n        \"_id\" : ObjectId(\"6154f37b7b36c03e7fbbab06\"),\n        \"username\" : \"gongu\",\n        \"favorites\" : {\n                \"movies\" : [\n                        \"mv1\"\n                ],\n                \"hobby\" : [\n                        \"h1\",\n                        \"h2\",\n                        \"h3\"\n                ]\n        }\n}\n{ \"_id\" : ObjectId(\"6154f4c67b36c03e7fbbab07\"), \"username\" : \"una\" }\n&gt; db.users.update({username:\"gongu\"},{$addToSet:{\"favorites.movies\":\"mv2\"}})\nWriteResult({ \"nMatched\" : 1, \"nUpserted\" : 0, \"nModified\" : 1 })\n&gt; db.users.find().pretty()\n{ \"_id\" : ObjectId(\"6154f18d7b36c03e7fbbab05\"), \"country\" : \"japan\" }\n{\n        \"_id\" : ObjectId(\"6154f37b7b36c03e7fbbab06\"),\n        \"username\" : \"gongu\",\n        \"favorites\" : {\n                \"movies\" : [\n                        \"mv1\",\n                        \"mv2\"\n                ],\n                \"hobby\" : [\n                        \"h1\",\n                        \"h2\",\n                        \"h3\"\n                ]\n        }\n}\n{ \"_id\" : ObjectId(\"6154f4c67b36c03e7fbbab07\"), \"username\" : \"una\" }\n&gt; db.users.update({username:\"gongu\"},{$push:{\"favorites.movies\":\"mv2\"}})\nWriteResult({ \"nMatched\" : 1, \"nUpserted\" : 0, \"nModified\" : 1 })\n&gt; db.users.find().pretty()\n{ \"_id\" : ObjectId(\"6154f18d7b36c03e7fbbab05\"), \"country\" : \"japan\" }\n{\n        \"_id\" : ObjectId(\"6154f37b7b36c03e7fbbab06\"),\n        \"username\" : \"gongu\",\n        \"favorites\" : {\n                \"movies\" : [\n                        \"mv1\",\n                        \"mv2\",\n                        \"mv2\"\n                ],\n                \"hobby\" : [\n                        \"h1\",\n                        \"h2\",\n                        \"h3\"\n                ]\n        }\n}\n{ \"_id\" : ObjectId(\"6154f4c67b36c03e7fbbab07\"), \"username\" : \"una\" }\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">$set\uc744 \uc774\uc6a9\ud558\uba74 MONGODB\uac00 \ucd94\uac00\ub418\uc9c0 \uc54a\uace0, \uae30\uc874 \ub370\uc774\ud130\ub97c \ubcc0\uacbd\ud574 \ubc84\ub838\ub2e4.<br>\ubc30\uc5f4\ud615\uc2dd\uc758 \ub370\uc774\ud130\ucd94\uac00\ub97c \ud560 \ub54c\ub294 $addToSet, $push\ub97c \uc0ac\uc6a9\ud55c\ub2e4.<br>$push\uc640 $addToSet\uc758 \ucc28\uc774\uc810\uc740&nbsp;$addToSet\uc740 \ub370\uc774\ud130\ub97c \ucd94\uac00\ud560\ub54c \uc911\ubcf5\ub41c\uac12\uc740 \uc5c5\ub370\uc774\ud2b8 \ud558\uc9c0 \uc54a\ub294\ub2e4.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\ub370\uc774\ud130 \uc0ad\uc81c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&gt; db.users.remove({username:\"una\"})\nWriteResult({ \"nRemoved\" : 1 })\n&gt; db.users.find()\n{ \"_id\" : ObjectId(\"6154f18d7b36c03e7fbbab05\"), \"country\" : \"japan\" }\n{ \"_id\" : ObjectId(\"6154f37b7b36c03e7fbbab06\"), \"username\" : \"gongu\", \"favorites\" : { \"movies\" : [ \"mv1\", \"mv2\", \"mv2\" ], \"hobby\" : [ \"h1\", \"h2\", \"h3\" ] } }\n&gt; db.users.drop()\ntrue\n&gt; db.users.find()\n&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">$remove() : \ub370\uc774\ud130\uc0ad\uc81c<br>$drop() : \uceec\ub809\uc158 \uc0ad\uc81c (\uceec\ub809\uc158\uc5d0 \ud3ec\ud568\ub418\uc5b4\uc788\ub358 \uc778\ub371\uc2a4\ub3c4 \ubaa8\ub450 \uc0ad\uc81c\ub41c\ub2e4)<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">\uc778\ub371\uc2a4 \uc0dd\uc131\uacfc \uc9c8\uc758<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Index\ub294 MongoDB\uc758 \ub370\uc774\ud130\ucffc\ub9ac\ub97c \ub354\uc6b1 \ud6a8\uc728\uc801\uc73c\ub85c \ud560 \uc218 \uc788\uac8c \ud574\uc900\ub2e4.<br>Index\uac00 \uc5c6\uc774\ub294 collection scan (\uceec\ub809\uc158 \ub370\uc774\ud130\ub97c \ud558\ub098\ud558\ub098) \uc73c\ub85c \uc870\ud68c\ud558\ubbc0\ub85c \ube44\ud6a8\uc728\uc801\uc778\ub2e4.<br>\ud55c \ucffc\ub9ac\ub2f9 \ud558\ub098\uc758 index\ub9cc \uc720\ud6a8\ud558\uba70, \ub450\uac1c\uc758 index\uac00 \ud544\uc694\ud558\ub2e4\uba74 \ubcf5\ud569 index\ub97c \uc0ac\uc6a9\ud55c\ub2e4.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uc0ac\uc6a9\uc2dc \uc8fc\uc758\ud560 \uc810<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">: \ubaa8\ub4e0 \uc778\ub371\uc2a4\ub97c \uac31\uc2e0\ud574\uc57c \ud558\uae30 \ub584\ubb38\uc5d0 \ubaa8\ub4e0 \uc4f0\uae30 \uc791\uc5c5\uc740 \uc778\ub371\uc2a4 \ub54c\ubb38\uc5d0 \ub354 \uc624\ub798 \uac78\ub9bc<br>: Collection \ub2f9 \ucd5c\ub300 64\uac1c\uae4c\uc9c0 \uc778\ub371\uc2a4\ub97c \uc9c0\ub2d0\uc218\uc788\uc9c0\ub9cc, 2~3\uac1c\ub9cc \uc9c0\ub2c8\ub294\uac8c \uc88b\ub2e4.<br>: \ubabd\uace0\ub514\ube44\uc758 \uc778\ub371\uc2a4\ub294 RDBMS\uc640 \uc720\uc0ac\ud558\uac8c \uc791\ub3d9\ud568<br>: \uc778\ub371\uc2a4 \uad6c\ucd95\uc2dc background \uc635\uc158\uc744 \uc0ac\uc6a9\ud558\uba74, \ube44\ub3d9\uae30\ub85c \uc791\uc5c5\uc774 \uac00\ub2a5\ud558\uae34\ud558\uc9c0\ub9cc \ub290\ub9ac\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&gt; for(i=0;i&lt;20000;i++){\n... db.numbers.save({num:i});\n... }\nWriteResult({ \"nInserted\" : 1 })\n&gt; db.numbers.count()\n20000\n&gt; db.numbers.find({num:{\"$gt\":19995}})\n{ \"_id\" : ObjectId(\"615504a22c5c13ab570becad\"), \"num\" : 19996 }\n{ \"_id\" : ObjectId(\"615504a22c5c13ab570becae\"), \"num\" : 19997 }\n{ \"_id\" : ObjectId(\"615504a22c5c13ab570becaf\"), \"num\" : 19998 }\n{ \"_id\" : ObjectId(\"615504a22c5c13ab570becb0\"), \"num\" : 19999 }\n&gt; db.numbers.find({num:{\"$gt\":19995,\"$lt\":19997}})\n{ \"_id\" : ObjectId(\"615504a22c5c13ab570becad\"), \"num\" : 19996 }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">it : more\uacfc \uac19\uc740 \uc5ed\ud560<br>$gt : greater than \/ $gte : greater than or equal to<br>$lt : less than \/ $lte : less than or equal to<br>$ne : not equal to<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&gt; db.numbers.createIndex({num:1})\n{\n        \"numIndexesBefore\" : 1,\n        \"numIndexesAfter\" : 2,\n        \"createdCollectionAutomatically\" : false,\n        \"ok\" : 1\n}\n&gt; db.numbers.getIndexes()\n[\n        {\n                \"v\" : 2,\n                \"key\" : {\n                        \"_id\" : 1\n                },\n                \"name\" : \"_id_\"\n        },\n        {\n                \"v\" : 2,\n                \"key\" : {\n                        \"num\" : 1\n                },\n                \"name\" : \"num_1\"\n        }\n]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">createIndex() : \uc778\ub371\uc2a4\uc0dd\uc131<br>getIndexes() : \uc778\ub371\uc2a4 \ud655\uc778<br>_id : \uc790\ub3d9\uc73c\ub85c pk\uc0dd\uc131<br>\uc778\ub371\uc2a4\uba85\uc744 \uc9c0\uc815\ud558\uc9c0 \uc54a\uc73c\uba74 \uc790\ub3d9\uc73c\ub85c \uc0dd\uc131<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&gt; db.numbers.find({num:{\"$gt\":19995}}).explain(\"executionStats\")\n{\n        \"explainVersion\" : \"1\",\n        \"queryPlanner\" : {\n                \"namespace\" : \"tutorial.numbers\",\n                \"indexFilterSet\" : false,\n                \"parsedQuery\" : {\n                        \"num\" : {\n                                \"$gt\" : 19995\n                        }\n                },\n                \"maxIndexedOrSolutionsReached\" : false,\n                \"maxIndexedAndSolutionsReached\" : false,\n                \"maxScansToExplodeReached\" : false,\n                \"winningPlan\" : {\n                        \"stage\" : \"FETCH\",\n                        \"inputStage\" : {\n                                \"stage\" : \"IXSCAN\",\n                                \"keyPattern\" : {\n                                        \"num\" : 1\n                                },\n                                \"indexName\" : \"num_1\",\n                                \"isMultiKey\" : false,\n                                \"multiKeyPaths\" : {\n                                        \"num\" : [ ]\n                                },\n                                \"isUnique\" : false,\n                                \"isSparse\" : false,\n                                \"isPartial\" : false,\n                                \"indexVersion\" : 2,\n                                \"direction\" : \"forward\",\n                                \"indexBounds\" : {\n                                        \"num\" : [\n                                                \"(19995.0, inf.0]\"\n                                        ]\n                                }\n                        }\n                },\n                \"rejectedPlans\" : [ ]\n        },\n        \"executionStats\" : {\n                \"executionSuccess\" : true,\n                \"nReturned\" : 4,\n                \"executionTimeMillis\" : 4,\n                \"totalKeysExamined\" : 4,\n                \"totalDocsExamined\" : 4,\n                \"executionStages\" : {\n                        \"stage\" : \"FETCH\",\n                        \"nReturned\" : 4,\n                        \"executionTimeMillisEstimate\" : 0,\n                        \"works\" : 5,\n                        \"advanced\" : 4,\n                        \"needTime\" : 0,\n                        \"needYield\" : 0,\n                        \"saveState\" : 0,\n                        \"restoreState\" : 0,\n                        \"isEOF\" : 1,\n                        \"docsExamined\" : 4,\n                        \"alreadyHasObj\" : 0,\n                        \"inputStage\" : {\n                                \"stage\" : \"IXSCAN\",\n                                \"nReturned\" : 4,\n                                \"executionTimeMillisEstimate\" : 0,\n                                \"works\" : 5,\n                                \"advanced\" : 4,\n                                \"needTime\" : 0,\n                                \"needYield\" : 0,\n                                \"saveState\" : 0,\n                                \"restoreState\" : 0,\n                                \"isEOF\" : 1,\n                                \"keyPattern\" : {\n                                        \"num\" : 1\n                                },\n                                \"indexName\" : \"num_1\",\n                                \"isMultiKey\" : false,\n                                \"multiKeyPaths\" : {\n                                        \"num\" : [ ]\n                                },\n                                \"isUnique\" : false,\n                                \"isSparse\" : false,\n                                \"isPartial\" : false,\n                                \"indexVersion\" : 2,\n                                \"direction\" : \"forward\",\n                                \"indexBounds\" : {\n                                        \"num\" : [\n                                                \"(19995.0, inf.0]\"\n                                        ]\n                                },\n                                \"keysExamined\" : 4,\n                                \"seeks\" : 1,\n                                \"dupsTested\" : 0,\n                                \"dupsDropped\" : 0\n                        }\n                }\n        },\n        \"command\" : {\n                \"find\" : \"numbers\",\n                \"filter\" : {\n                        \"num\" : {\n                                \"$gt\" : 19995\n                        }\n                },\n                \"$db\" : \"tutorial\"\n        },\n        \"serverInfo\" : {\n                \"host\" : \"\ufffd\u0338\ufffd\ufffd\ufffd-PC\",\n                \"port\" : 27017,\n                \"version\" : \"5.0.3\",\n                \"gitVersion\" : \"657fea5a61a74d7a79df7aff8e4bcf0bc742b748\"\n        },\n        \"serverParameters\" : {\n                \"internalQueryFacetBufferSizeBytes\" : 104857600,\n                \"internalQueryFacetMaxOutputDocSizeBytes\" : 104857600,\n                \"internalLookupStageIntermediateDocumentMaxSizeBytes\" : 104857600,\n                \"internalDocumentSourceGroupMaxMemoryBytes\" : 104857600,\n                \"internalQueryMaxBlockingSortMemoryUsageBytes\" : 104857600,\n                \"internalQueryProhibitBlockingMergeOnMongoS\" : 0,\n                \"internalQueryMaxAddToSetBytes\" : 104857600,\n                \"internalDocumentSourceSetWindowFieldsMaxMemoryBytes\" : 104857600\n        },\n        \"ok\" : 1\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">num\uc5d0 \ub300\ud55c \uc778\ub371\uc2a4 num_1\uc744 \uc0ac\uc6a9\ud558\ubbc0\ub85c \ucffc\ub9ac\uc5d0 \ud574\ub2f9\ud558\ub294 4\uac1c\uc758 \ub3c4\ud050\uba3c\ud2b8\ub9cc\uc744 \uc2a4\uce94\ud558\uace0 \ucffc\ub9ac \uc2e4\ud589\uc2dc\uac04\ub3c4 \uc904\uc5b4\ub4e0\ub2e4.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">\uae30\ubcf8\uc801\uc778 \uad00\ub9ac<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&gt; show dbs\nadmin     0.000GB\nconfig    0.000GB\nlocal     0.000GB\ntutorial  0.001GB\n&gt; show collections\nnumbers\n&gt; db.stats()\n{\n        \"db\" : \"tutorial\",\n        \"collections\" : 1,\n        \"views\" : 0,\n        \"objects\" : 20000,\n        \"avgObjSize\" : 35,\n        \"dataSize\" : 700000,\n        \"storageSize\" : 262144,\n        \"freeStorageSize\" : 0,\n        \"indexes\" : 2,\n        \"indexSize\" : 462848,\n        \"indexFreeStorageSize\" : 0,\n        \"totalSize\" : 724992,\n        \"totalFreeStorageSize\" : 0,\n        \"scaleFactor\" : 1,\n        \"fsUsedSize\" : 105793134592,\n        \"fsTotalSize\" : 495558197248,\n        \"ok\" : 1\n}\n&gt; db.numbers.stats()\n{\n        \"ns\" : \"tutorial.numbers\",\n        \"size\" : 700000,\n        \"count\" : 20000,\n        \"avgObjSize\" : 35,\n        \"storageSize\" : 262144,\n        \"freeStorageSize\" : 0,\n        \"capped\" : false,\n        \"wiredTiger\" : {\n                \"metadata\" : {\n                        \"formatVersion\" : 1\n                },\n                \"creationString\" : \"access_pattern_hint=none,allocation_size=4KB,app_metadata=(formatVersion=1),assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none,write_timestamp=off),block_allocation=best,block_compressor=snappy,cache_resident=false,checksum=on,colgroups=,collator=,columns=,dictionary=0,encryption=(keyid=,name=),exclusive=false,extractor=,format=btree,huffman_key=,huffman_value=,ignore_in_memory_cache_size=false,immutable=false,import=(enabled=false,file_metadata=,repair=false),internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=q,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=64MB,log=(enabled=true),lsm=(auto_throttle=true,bloom=true,bloom_bit_count=16,bloom_config=,bloom_hash_count=8,bloom_oldest=false,chunk_count_limit=0,chunk_max=5GB,chunk_size=10MB,merge_custom=(prefix=,start_generation=0,suffix=),merge_max=15,merge_min=0),memory_page_image_max=0,memory_page_max=10m,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,readonly=false,source=,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,tiered_object=false,tiered_storage=(auth_token=,bucket=,bucket_prefix=,local_retention=300,name=,object_target_size=10M),type=file,value_format=u,verbose=[],write_timestamp_usage=none\",\n                \"type\" : \"file\",\n                \"uri\" : \"statistics:table:collection-9-1214493195749372225\",\n                \"LSM\" : {\n                        \"bloom filter false positives\" : 0,\n                        \"bloom filter hits\" : 0,\n                        \"bloom filter misses\" : 0,\n                        \"bloom filter pages evicted from cache\" : 0,\n                        \"bloom filter pages read into cache\" : 0,\n                        \"bloom filters in the LSM tree\" : 0,\n                        \"chunks in the LSM tree\" : 0,\n                        \"highest merge generation in the LSM tree\" : 0,\n                        \"queries that could have benefited from a Bloom filter that did not exist\" : 0,\n                        \"sleep for LSM checkpoint throttle\" : 0,\n                        \"sleep for LSM merge throttle\" : 0,\n                        \"total size of bloom filters\" : 0\n                },\n                \"block-manager\" : {\n                        \"allocations requiring file extension\" : 10,\n                        \"blocks allocated\" : 10,\n                        \"blocks freed\" : 0,\n                        \"checkpoint size\" : 245760,\n                        \"file allocation unit size\" : 4096,\n                        \"file bytes available for reuse\" : 0,\n                        \"file magic number\" : 120897,\n                        \"file major version number\" : 1,\n                        \"file size in bytes\" : 262144,\n                        \"minor version number\" : 0\n                },\n                \"btree\" : {\n                        \"btree checkpoint generation\" : 145,\n                        \"btree clean tree checkpoint expiration time\" : NumberLong(\"9223372036854775807\"),\n                        \"column-store fixed-size leaf pages\" : 0,\n                        \"column-store internal pages\" : 0,\n                        \"column-store variable-size RLE encoded values\" : 0,\n                        \"column-store variable-size deleted values\" : 0,\n                        \"column-store variable-size leaf pages\" : 0,\n                        \"fixed-record size\" : 0,\n                        \"maximum internal page key size\" : 368,\n                        \"maximum internal page size\" : 4096,\n                        \"maximum leaf page key size\" : 2867,\n                        \"maximum leaf page size\" : 32768,\n                        \"maximum leaf page value size\" : 67108864,\n                        \"maximum tree depth\" : 3,\n                        \"number of key\/value pairs\" : 0,\n                        \"overflow pages\" : 0,\n                        \"pages rewritten by compaction\" : 0,\n                        \"row-store empty values\" : 0,\n                        \"row-store internal pages\" : 0,\n                        \"row-store leaf pages\" : 0\n                },\n                \"cache\" : {\n                        \"bytes currently in the cache\" : 2706915,\n                        \"bytes dirty in the cache cumulative\" : 865,\n                        \"bytes read into cache\" : 0,\n                        \"bytes written from cache\" : 791840,\n                        \"checkpoint blocked page eviction\" : 0,\n                        \"checkpoint of history store file blocked non-history store page eviction\" : 0,\n                        \"data source pages selected for eviction unable to be evicted\" : 0,\n                        \"eviction gave up due to detecting an out of order on disk value behind the last update on the chain\" : 0,\n                        \"eviction gave up due to detecting an out of order tombstone ahead of the selected on disk update\" : 0,\n                        \"eviction gave up due to detecting an out of order tombstone ahead of the selected on disk update after validating the update chain\" : 0,\n                        \"eviction gave up due to detecting out of order timestamps on the update chain after the selected on disk update\" : 0,\n                        \"eviction walk passes of a file\" : 0,\n                        \"eviction walk target pages histogram - 0-9\" : 0,\n                        \"eviction walk target pages histogram - 10-31\" : 0,\n                        \"eviction walk target pages histogram - 128 and higher\" : 0,\n                        \"eviction walk target pages histogram - 32-63\" : 0,\n                        \"eviction walk target pages histogram - 64-128\" : 0,\n                        \"eviction walk target pages reduced due to history store cache pressure\" : 0,\n                        \"eviction walks abandoned\" : 0,\n                        \"eviction walks gave up because they restarted their walk twice\" : 0,\n                        \"eviction walks gave up because they saw too many pages and found no candidates\" : 0,\n                        \"eviction walks gave up because they saw too many pages and found too few candidates\" : 0,\n                        \"eviction walks reached end of tree\" : 0,\n                        \"eviction walks restarted\" : 0,\n                        \"eviction walks started from root of tree\" : 0,\n                        \"eviction walks started from saved location in tree\" : 0,\n                        \"hazard pointer blocked page eviction\" : 0,\n                        \"history store table insert calls\" : 0,\n                        \"history store table insert calls that returned restart\" : 0,\n                        \"history store table out-of-order resolved updates that lose their durable timestamp\" : 0,\n                        \"history store table out-of-order updates that were fixed up by reinserting with the fixed timestamp\" : 0,\n                        \"history store table reads\" : 0,\n                        \"history store table reads missed\" : 0,\n                        \"history store table reads requiring squashed modifies\" : 0,\n                        \"history store table truncation by rollback to stable to remove an unstable update\" : 0,\n                        \"history store table truncation by rollback to stable to remove an update\" : 0,\n                        \"history store table truncation to remove an update\" : 0,\n                        \"history store table truncation to remove range of updates due to key being removed from the data page during reconciliation\" : 0,\n                        \"history store table truncation to remove range of updates due to out-of-order timestamp update on data page\" : 0,\n                        \"history store table writes requiring squashed modifies\" : 0,\n                        \"in-memory page passed criteria to be split\" : 0,\n                        \"in-memory page splits\" : 0,\n                        \"internal pages evicted\" : 0,\n                        \"internal pages split during eviction\" : 0,\n                        \"leaf pages split during eviction\" : 0,\n                        \"modified pages evicted\" : 0,\n                        \"overflow pages read into cache\" : 0,\n                        \"page split during eviction deepened the tree\" : 0,\n                        \"page written requiring history store records\" : 0,\n                        \"pages read into cache\" : 0,\n                        \"pages read into cache after truncate\" : 1,\n                        \"pages read into cache after truncate in prepare state\" : 0,\n                        \"pages requested from the cache\" : 20066,\n                        \"pages seen by eviction walk\" : 0,\n                        \"pages written from cache\" : 8,\n                        \"pages written requiring in-memory restoration\" : 0,\n                        \"tracked dirty bytes in the cache\" : 0,\n                        \"unmodified pages evicted\" : 0\n                },\n                \"cache_walk\" : {\n                        \"Average difference between current eviction generation when the page was last considered\" : 0,\n                        \"Average on-disk page image size seen\" : 0,\n                        \"Average time in cache for pages that have been visited by the eviction server\" : 0,\n                        \"Average time in cache for pages that have not been visited by the eviction server\" : 0,\n                        \"Clean pages currently in cache\" : 0,\n                        \"Current eviction generation\" : 0,\n                        \"Dirty pages currently in cache\" : 0,\n                        \"Entries in the root page\" : 0,\n                        \"Internal pages currently in cache\" : 0,\n                        \"Leaf pages currently in cache\" : 0,\n                        \"Maximum difference between current eviction generation when the page was last considered\" : 0,\n                        \"Maximum page size seen\" : 0,\n                        \"Minimum on-disk page image size seen\" : 0,\n                        \"Number of pages never visited by eviction server\" : 0,\n                        \"On-disk page image sizes smaller than a single allocation unit\" : 0,\n                        \"Pages created in memory and never written\" : 0,\n                        \"Pages currently queued for eviction\" : 0,\n                        \"Pages that could not be queued for eviction\" : 0,\n                        \"Refs skipped during cache traversal\" : 0,\n                        \"Size of the root page\" : 0,\n                        \"Total number of pages currently in cache\" : 0\n                },\n                \"checkpoint-cleanup\" : {\n                        \"pages added for eviction\" : 0,\n                        \"pages removed\" : 0,\n                        \"pages skipped during tree walk\" : 0,\n                        \"pages visited\" : 1\n                },\n                \"compression\" : {\n                        \"compressed page maximum internal page size prior to compression\" : 4096,\n                        \"compressed page maximum leaf page size prior to compression \" : 111416,\n                        \"compressed pages read\" : 0,\n                        \"compressed pages written\" : 7,\n                        \"page written failed to compress\" : 0,\n                        \"page written was too small to compress\" : 1\n                },\n                \"cursor\" : {\n                        \"Total number of entries skipped by cursor next calls\" : 0,\n                        \"Total number of entries skipped by cursor prev calls\" : 0,\n                        \"Total number of entries skipped to position the history store cursor\" : 0,\n                        \"Total number of pages skipped without reading by cursor next calls\" : 0,\n                        \"Total number of pages skipped without reading by cursor prev calls\" : 0,\n                        \"Total number of times a search near has exited due to prefix config\" : 0,\n                        \"bulk loaded cursor insert calls\" : 0,\n                        \"cache cursors reuse count\" : 20004,\n                        \"close calls that result in cache\" : 20006,\n                        \"create calls\" : 4,\n                        \"cursor next calls that skip due to a globally visible history store tombstone\" : 0,\n                        \"cursor next calls that skip greater than or equal to 100 entries\" : 0,\n                        \"cursor next calls that skip less than 100 entries\" : 60005,\n                        \"cursor prev calls that skip due to a globally visible history store tombstone\" : 0,\n                        \"cursor prev calls that skip greater than or equal to 100 entries\" : 0,\n                        \"cursor prev calls that skip less than 100 entries\" : 1,\n                        \"insert calls\" : 20000,\n                        \"insert key and value bytes\" : 751426,\n                        \"modify\" : 0,\n                        \"modify key and value bytes affected\" : 0,\n                        \"modify value bytes modified\" : 0,\n                        \"next calls\" : 60005,\n                        \"open cursor count\" : 0,\n                        \"operation restarted\" : 0,\n                        \"prev calls\" : 1,\n                        \"remove calls\" : 0,\n                        \"remove key bytes removed\" : 0,\n                        \"reserve calls\" : 0,\n                        \"reset calls\" : 40073,\n                        \"search calls\" : 4,\n                        \"search history store calls\" : 0,\n                        \"search near calls\" : 60,\n                        \"truncate calls\" : 0,\n                        \"update calls\" : 0,\n                        \"update key and value bytes\" : 0,\n                        \"update value size change\" : 0\n                },\n                \"reconciliation\" : {\n                        \"approximate byte size of timestamps in pages written\" : 0,\n                        \"approximate byte size of transaction IDs in pages written\" : 0,\n                        \"dictionary matches\" : 0,\n                        \"fast-path pages deleted\" : 0,\n                        \"internal page key bytes discarded using suffix compression\" : 13,\n                        \"internal page multi-block writes\" : 0,\n                        \"internal-page overflow keys\" : 0,\n                        \"leaf page key bytes discarded using prefix compression\" : 0,\n                        \"leaf page multi-block writes\" : 1,\n                        \"leaf-page overflow keys\" : 0,\n                        \"maximum blocks required for a page\" : 1,\n                        \"overflow values written\" : 0,\n                        \"page checksum matches\" : 0,\n                        \"page reconciliation calls\" : 2,\n                        \"page reconciliation calls for eviction\" : 0,\n                        \"pages deleted\" : 0,\n                        \"pages written including an aggregated newest start durable timestamp \" : 0,\n                        \"pages written including an aggregated newest stop durable timestamp \" : 0,\n                        \"pages written including an aggregated newest stop timestamp \" : 0,\n                        \"pages written including an aggregated newest stop transaction ID\" : 0,\n                        \"pages written including an aggregated newest transaction ID \" : 0,\n                        \"pages written including an aggregated oldest start timestamp \" : 0,\n                        \"pages written including an aggregated prepare\" : 0,\n                        \"pages written including at least one prepare\" : 0,\n                        \"pages written including at least one start durable timestamp\" : 0,\n                        \"pages written including at least one start timestamp\" : 0,\n                        \"pages written including at least one start transaction ID\" : 0,\n                        \"pages written including at least one stop durable timestamp\" : 0,\n                        \"pages written including at least one stop timestamp\" : 0,\n                        \"pages written including at least one stop transaction ID\" : 0,\n                        \"records written including a prepare\" : 0,\n                        \"records written including a start durable timestamp\" : 0,\n                        \"records written including a start timestamp\" : 0,\n                        \"records written including a start transaction ID\" : 0,\n                        \"records written including a stop durable timestamp\" : 0,\n                        \"records written including a stop timestamp\" : 0,\n                        \"records written including a stop transaction ID\" : 0\n                },\n                \"session\" : {\n                        \"object compaction\" : 0,\n                        \"tiered operations dequeued and processed\" : 0,\n                        \"tiered operations scheduled\" : 0,\n                        \"tiered storage local retention time (secs)\" : 0,\n                        \"tiered storage object size\" : 0\n                },\n                \"transaction\" : {\n                        \"race to read prepared update retry\" : 0,\n                        \"rollback to stable history store records with stop timestamps older than newer records\" : 0,\n                        \"rollback to stable inconsistent checkpoint\" : 0,\n                        \"rollback to stable keys removed\" : 0,\n                        \"rollback to stable keys restored\" : 0,\n                        \"rollback to stable restored tombstones from history store\" : 0,\n                        \"rollback to stable restored updates from history store\" : 0,\n                        \"rollback to stable skipping delete rle\" : 0,\n                        \"rollback to stable skipping stable rle\" : 0,\n                        \"rollback to stable sweeping history store keys\" : 0,\n                        \"rollback to stable updates removed from history store\" : 0,\n                        \"transaction checkpoints due to obsolete pages\" : 0,\n                        \"update conflicts\" : 0\n                }\n        },\n        \"nindexes\" : 2,\n        \"indexBuilds\" : [ ],\n        \"totalIndexSize\" : 462848,\n        \"totalSize\" : 724992,\n        \"indexSizes\" : {\n                \"_id_\" : 225280,\n                \"num_1\" : 237568\n        },\n        \"scaleFactor\" : 1,\n        \"ok\" : 1\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">show dbs : \uc2dc\uc2a4\ud15c\uc0c1\uc758 \ubaa8\ub4e0 \ub370\uc774\ud130\ubca0\uc774\uc2a4\ub97c \ubcf4\uc5ec\uc900\ub2e4.<br>show collections : \ud604\uc7ac \uc0ac\uc6a9 \uc911\uc778 \ub370\uc774\ud130\ubca0\uc774\uc2a4\uc5d0\uc11c \uc815\uc758\ub41c \ubaa8\ub4e0 \uceec\ub809\uc158\uc744 \ubcf4\uc5ec\uc900\ub2e4.<br>stats() : \uc880 \ub354 \ud558\uc704 \uacc4\uce35\uc758 \uc815\ubcf4\ub97c \uc5bb\uc744 \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&gt; db.runCommand\nfunction(obj, extra, queryOptions) {\n    \"use strict\";\n\n    \/\/ Support users who call this function with a string commandName, e.g.\n    \/\/ db.runCommand(\"commandName\", {arg1: \"value\", arg2: \"value\"}).\n    var mergedObj = this._mergeCommandOptions(obj, extra);\n\n    \/\/ if options were passed (i.e. because they were overridden on a collection), use them.\n    \/\/ Otherwise use getQueryOptions.\n    var options = (typeof (queryOptions) !== \"undefined\") ? queryOptions : this.getQueryOptions();\n\n    try {\n        return this._runCommandImpl(this._name, mergedObj, options);\n    } catch (ex) {\n        \/\/ When runCommand flowed through query, a connection error resulted in the message\n        \/\/ \"error doing query: failed\". Even though this message is arguably incorrect\n        \/\/ for a command failing due to a connection failure, we preserve it for backwards\n        \/\/ compatibility. See SERVER-18334 for details.\n        if (ex.message.indexOf(\"network error\") &gt;= 0) {\n            throw new Error(\"error doing query: failed: \" + ex.message);\n        }\n        throw ex;\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\uba85\ub839\uc5b4\uac00 \uc791\ub3d9\ud558\ub294 \ubc29\uc2dd.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">\ub3c4\uc6c0\ub9d0 \uc5bb\uae30<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">db.help() : \ub370\uc774\ud130\ubca0\uc774\uc2a4\uc5d0 \ub300\ud574 \uc77c\ubc18\uc801\uc73c\ub85c \uc218\uc57b\ub418\ub294 \uba54\uc11c\ub4dc\uc758 \ub9ac\uc2a4\ud2b8\ub97c \ubcf4\uc5ec\uc900\ub2e4.<br>db.numbers.help() : \uceec\ub809\uc158\uc5d0 \ub300\ud574 \uc218\ud589\ub418\ub294 \uba54\uc11c\ub4dc\ub97c \ubcf4\uc5ec\uc900\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&gt; db.numbers.save({num:111111111111})\nWriteResult({ \"nInserted\" : 1 })\n&gt; db.numbers.save\nfunction(obj, opts) {\n    if (obj == null)\n        throw Error(\"can't save a null\");\n\n    if (typeof (obj) == \"number\" || typeof (obj) == \"string\")\n        throw Error(\"can't save a number or string\");\n\n    if (typeof (obj._id) == \"undefined\") {\n        obj._id = new ObjectId();\n        return this.insert(obj, opts);\n    } else {\n        return this.update({_id: obj._id}, obj, Object.merge({upsert: true}, opts));\n    }\n}\n&gt; db.numbers.insert\nfunction(obj, options) {\n    if (!obj)\n        throw Error(\"no object passed to insert!\");\n\n    options = typeof (options) === 'undefined' ? {} : options;\n\n    var flags = 0;\n\n    var wc = undefined;\n    var allowDottedFields = false;\n    if (options === undefined) {\n        \/\/ do nothing\n    } else if (typeof (options) == 'object') {\n        if (options.ordered === undefined) {\n            \/\/ do nothing, like above\n        } else {\n            flags = options.ordered ? 0 : 1;\n        }\n\n        if (options.writeConcern)\n            wc = options.writeConcern;\n        if (options.allowdotted)\n            allowDottedFields = true;\n    } else {\n        flags = options;\n    }\n\n    \/\/ 1 = continueOnError, which is synonymous with unordered in the write commands\/bulk-api\n    var ordered = ((flags &amp; 1) == 0);\n\n    if (!wc)\n        wc = this._createWriteConcern(options);\n\n    var result = undefined;\n    var startTime =\n        (typeof (_verboseShell) === 'undefined' || !_verboseShell) ? 0 : new Date().getTime();\n\n    if (this.getMongo().writeMode() != \"legacy\") {\n        \/\/ Bit 1 of option flag is continueOnError. Bit 0 (stop on error) is the default.\n        var bulk = ordered ? this.initializeOrderedBulkOp() : this.initializeUnorderedBulkOp();\n        var isMultiInsert = Array.isArray(obj);\n\n        if (isMultiInsert) {\n            obj.forEach(function(doc) {\n                bulk.insert(doc);\n            });\n        } else {\n            bulk.insert(obj);\n        }\n\n        try {\n            result = bulk.execute(wc);\n            if (!isMultiInsert)\n                result = result.toSingleResult();\n        } catch (ex) {\n            if (ex instanceof BulkWriteError) {\n                result = isMultiInsert ? ex.toResult() : ex.toSingleResult();\n            } else if (ex instanceof WriteCommandError) {\n                result = ex;\n            } else {\n                \/\/ Other exceptions rethrown as-is.\n                throw ex;\n            }\n        }\n    } else {\n        if (typeof (obj._id) == \"undefined\" &amp;&amp; !Array.isArray(obj)) {\n            var tmp = obj;  \/\/ don't want to modify input\n            obj = {_id: new ObjectId()};\n            for (var key in tmp) {\n                obj[key] = tmp[key];\n            }\n        }\n\n        this.getMongo().insert(this._fullName, obj, flags);\n\n        \/\/ enforce write concern, if required\n        if (wc)\n            result = this.runCommand(\"getLastError\", wc instanceof WriteConcern ? wc.toJSON() : wc);\n    }\n\n    this._lastID = obj._id;\n    this._printExtraInfo(\"Inserted\", startTime);\n    return result;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">save \uc640 insert\uc758 \ubc29\uc2dd\uc744 \uc54c\uace0\uc2f6\uc744 \uacbd\uc6b0 \uc5b4\ub5bb\uac8c \uad6c\ud604\ub418\uc5b4\uc788\ub294\uc9c0 \ud655\uc778\ud574\ubcf4\uc790.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8 \uc178\uc744 \ud1b5\ud55c MongoDB \ub2e4\ub978 \ud234\uacfc \ub2e4\ub978 \uc810\uc740 \ucffc\ub9ac \uc5b8\uc5b4\uc5d0 \uc788\ub2e4. SQL\uacfc \uac19\uc774 \ud45c\uc900\ud654\ub41c \ucffc\ub9ac \uc5b8\uc5b4\ub97c \uc0ac\uc6a9\ud558\ub294 \uac83 \ub300\uc2e0\uc5d0 \uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8 \ud504\ub85c\uadf8\ub798\ubc0d \uc5b8\uc5b4\uc640 \uac04\ub2e8\ud55c API\ub97c \uc0ac\uc6a9\ud574 \uc11c\ubc84\uc640 \uc5f0\uacb0\ud55c\ub2e4. MongoDB\uc124\uce58(\ubd80\ub85dA) \uc708\ub3c4\uc6b0 \uc124\uce58 \uc6d0\ub3c4\uc6b0 \uba85\ub839\ud504\ub86c\ud504\ud2b8(\ucee4\ub9e8\ub4dc\ucc3d)\uc5d0\uc11c\ub3c4 \uba85\ub839\uc5b4\ub85c \uc811\uc18d\uc774 \uac00\ub2a5\ud558\ub3c4\ub85d Path\ub97c \uc124\uc815\uc81c\uc5b4\ud310 &gt; \ud658\uacbd\ubcc0\uc218 &gt; \uc2dc\uc2a4\ud15cPath &gt; \ubabd\uace0\ub514\ube44\uc124\uce58 bin\uacbd\ub85c \ucd94\uac00 (C:\\Program Files\\MongoDB\\Server\\5.0\\bin) \ub370\uc774\ud130\ubca0\uc774\uc2a4, \uceec\ub809\uc158, \ub3c4\ud050\uba3c\ud2b8 MongoDB\uac00 RDBMS\uc758 \ud14c\uc774\ube14\uacfc \uac19\uc774 \ub3c4\ud050\uba3c\ud2b8\ub4e4\uc744 &#8230; <a title=\"\ubabd\uace0\ub514\ube44 \uc778 \uc561\uc158 2\uc7a5\" class=\"read-more\" href=\"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/2021\/09\/30\/%eb%aa%bd%ea%b3%a0%eb%94%94%eb%b9%84-%ec%9d%b8-%ec%95%a1%ec%85%98-2%ec%9e%a5\/\" aria-label=\"Read more about \ubabd\uace0\ub514\ube44 \uc778 \uc561\uc158 2\uc7a5\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-662","post","type-post","status-publish","format-standard","hentry","category-4"],"_links":{"self":[{"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=662"}],"version-history":[{"count":4,"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/662\/revisions"}],"predecessor-version":[{"id":720,"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/662\/revisions\/720"}],"wp:attachment":[{"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}