聽 聽 聽 聽 涓婁竴绡?/a>涓?垜浠?凡缁忚兘澶熸?甯稿惎鍔╩ongodb浜嗭紝鎺ョ潃涓婁竴绡囨垜浠?紑瀛︿範mongodb鐨刯avascript shell 鐨勪娇鐢?紙鍖呮嫭瀵规暟鎹?殑crud鎿嶄綔锛夈??/p>
聽 聽 聽 聽 聽鐜板湪棣栧厛璁╂垜浠?櫥褰昺ongodb鏈嶅姟鍣?紝鍦╩ongodb鎵?鍦ㄦ牴鐩?綍涓?殑bin鐩?綍涓嬫湁涓?涓猰ongo.exe,杩欎釜鏄痬ongodb鎻愪緵鐨勪竴涓??鎴风?绋嬪簭銆傛垜浠?弻鍑昏繍琛屽畠锛?/p>
聽 聽 聽 聽 濡傛灉鍚?姩鏃舵病鏈夌煡閬撳叾浠栨暟鎹?簱锛宮ongodb浼氶?夋嫨涓?涓?彨test鐨勯粯璁ゆ暟鎹?簱锛屾垜浠?幇鍦ㄦ祴璇曠敤锛屽氨鐢╰est鏁版嵁搴撳惂锛佸綋鐒朵綘涔熷彲浠ュ垏鎹㈠埌鍏朵粬鏁版嵁搴撳幓锛岀敤鍛戒护鈥渦ser XXX;鈥?鍏朵腑XXX灏辨槸鏁版嵁搴撶殑鍚嶇О銆傝繖閲岄渶瑕佹敞鎰忕殑鏄?彧鏈夊綋寰?XXX鏁版嵁搴撲腑鎻掑叆涓?鏉¤?褰曞悗XXX鏁版嵁搴撴墠浼氬垱寤恒??/p>
聽 聽 聽 聽 鎺ヤ笅鏉ワ紝璁╂垜浠?潵鍒涘缓涓?涓?枃妗e惂锛佸洜涓簃ongodb浣跨敤鐨勬槸javaScript Shell锛屾墍浠ユ垜浠?皢鐢↗SON鏉ユ弿杩版枃浠躲?傚垱寤轰竴涓?敤鎴蜂俊鎭?殑鏂囨。渚挎槸锛?/p>
user1 = {userName:"zhangsan",password:"123456"}
user1鐨勬枃妗e垱寤哄ソ鍚庯紝灏卞彲浠ュ皢user1鎻掑叆鏁版嵁涓?簡锛?/p>
db.users.insert(user1);灏辫繖鏍穟ser1渚挎彃鍏ュ埌闆嗗悎users涓?簡锛屽綋鐒朵簡浣犱篃鍙?互鐩存帴鐢?細
db.users.insert({userName:"zhangsan",password:"123456"})鏂瑰紡鎻掑叆鏁版嵁銆?/p>
鐜板湪璁╂垜浠?獙璇佷竴涓嬶紝杩欎釜user1鏄?凡缁忓瓨鍦╱sers闆嗗悎涓?細
db.users.find();聽
聽杩欓噷闇?瑕佹寚鍑虹殑鏄?紝鏂囨。涓?嚜鍔ㄦ坊鍔犱簡_id瀛楁?锛屽叾瀹炲畠灏辨槸mongodb涓烘病鏈夋樉绀虹殑鎻愪緵_id锛堜富閿?級鐨勬枃妗g敓鎴愮殑涓?涓?壒娈奙ongoDB瀵硅薄id銆?/p>
聽 聽 聽 聽 褰撶劧淇濆瓨鍦ㄩ泦鍚坲sers涓?殑鏁版嵁鏄?彲浠ヤ慨鏀圭殑锛岄偅涔堝湪mongodb涓?槸鎬庝箞淇?敼杩欐潯鏁版嵁鐨勫憿锛熸帴涓嬫潵鎴戜滑灏嗗垰鎵嶄繚瀛樿繘鍘诲悕瀛椾负鈥渮hangsan鈥濈殑user1鏀瑰悕涓衡?渓isi鈥濄??/p>
db.users.update({userName:"zhangsan"},{$set:{userName:"lisi"}});
鐜板湪鎴戜滑鍐嶆煡瀵讳竴涓媢sers闆嗗悎锛岀湅鐪嬬敤鎴峰悕鏄?惁宸茬粡淇?敼銆?/p>
聽鏌ョ湅寰楃煡锛岀敤鎴峰悕纭?疄宸茬粡淇?负涓衡?渓isi鈥濄??/p>
聽 聽 聽 聽 聽鎺ヤ笅鏉ワ紝鎴戜滑灏嗚繖鏉?ser鏂囨。鍒犻櫎鎺夛細
db.users.remove({userName:"lisi"});
鐒跺悗鎴戜滑鍐嶈繍琛岋細db.users.find();
聽鐢辨?鍙??鏂囨。宸茬粡琚?垹闄ゃ??/p>
mongodb绠?鍗曠殑crud鎴戜滑灏卞?涔犲埌杩欓噷锛屽湪浠ュ悗鐨勫?涔犱腑锛屽皢浼氭洿娣卞叆鐨勪簡瑙o紒
聽