How to use MongoDB

1.mongo view the test configuration file

db.TABLE_NAME.find({type:"dev"})  

2. View the update time flashback of nation_name country daily report

db.TABLE_NAME.find({Nation_Name:"中国"}).sort({ CreateTime:-1 })

3. Show or hide the corresponding field 0 means hide, 1 means display

db.TABLE_NAME.find({},{ Nation_Name:1 }).sort({ CreateTime:-1 }) -- Query the latest data Nation_Name field

4.时间选择
db.TABLE_NAME.find({"CreateTime":{$lt:new Date(2018,2,30),$gte:new Date(2018,2,29)}}).sort({ReportTime:1 })

db.TABLE_NAME.find({ 

"reportTime":{"$gte":ISODate("2018-04-09T00:00:00.000+08:00"), "$lt":ISODate("2018-04-10T00:00:00.000+08:00")}

})

5. Not equal to {$ne:1}

db.TABLE_NAME.find({"Machine_Model":"1","County_Code":{$ne:""},"ReportTime":ISODate("2018-04-14T00:00:00.000+08:00")},{LoginID:1,Area_Code:1,County_Code:1,Machine_Model:1,Longitude:1,Latitude:1}) 

6. Delete data

db.TABLE_NAME.remove();

7. Delete Table

db.TABLE_NAME.drop();












Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324690398&siteId=291194637