일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 김양재 목사님
- Statistics
- 우리들교회
- 확률
- data science
- openCV
- 김양재
- 김양재 목사
- 빅 데이타
- 데이터 과학
- 빅데이터
- WebGL
- Artificial Intelligence
- Machine Learning
- Deep learning
- No SQL
- 몽고디비
- 인공지능
- probability
- 빅 데이터
- nodeJS
- R
- c++
- 빅데이타
- MongoDB
- 딥러닝
- node.js
- Big Data
- 주일설교
- 통계
Archives
- Today
- Total
Scientific Computing & Data Science
[MongoDB] Update Modifiers / Part.1 - $inc 본문
Written by cinema4d
Sometimes you may want to modify only a certain portion of document.
Using update modifiers you can do that by atomic level such as altering, adding or removing keys and even manipulating arrays and embedded documents.
Assume that you have three webpages to manage and you are going to update pageviews - automatically increase by 1 when visiting.
Type the following for data preparations :
// user DB "foobar"
use foobar
// define webpage1
var page1 = {"url" : "www.gchoi.net", "pageviews" : 100}
// define webpage2
var page2 = {"url" : "www.google.com", "pageviews" : 1000}
// define webpage3
var page3 = {"url" : "www.apple.com", "pageviews" : 500}
// insert items into DB
db.analytics.insert(page1)
db.analytics.insert(page2)
db.analytics.insert(page3)
db.analytics.find()
Increase pageviews of url "www.gchoi.net" by 1 :
// increase pageviews of url "www.gchoi.net" by 1
db.analytics.update({"url" : "www.gchoi.net"},{"$inc" : {"pageviews" : 1}})
db.analytics.findOne({"url" : "www.gchoi.net"})
'Data Science > MongoDB' 카테고리의 다른 글
[MongoDB] Application / Execute MongoDB Server on Windows (0) | 2014.01.20 |
---|---|
[MongoDB] Update Modifiers / Part. 2 - $set / $unset (0) | 2014.01.19 |
[MongoDB] Updating Documents by Document Replacement (0) | 2014.01.19 |
[MongoDB] Basic / Life Cycle for MongoDB (0) | 2014.01.19 |
[MongoDB] MongDB 기본명령어 (0) | 2014.01.13 |
Comments