일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- WebGL
- Machine Learning
- 몽고디비
- 통계
- 김양재 목사님
- 빅데이터
- 빅데이타
- 김양재 목사
- Big Data
- 주일설교
- No SQL
- 빅 데이터
- R
- 빅 데이타
- 우리들교회
- 인공지능
- c++
- 김양재
- Statistics
- Artificial Intelligence
- 데이터 과학
- nodeJS
- openCV
- Deep learning
- MongoDB
- probability
- 딥러닝
- 확률
- data science
- node.js
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