NoSql 썸네일형 리스트형 SQL to Mongo Mapping Chart http://www.mongodb.org/display/DOCS/SQL+to+Mongo+Mapping+Chart 더보기 mongodb 다루기 3 package org.springframework.data.mongodb.examples.mongo; import static org.junit.Assert.*; import static org.hamcrest.CoreMatchers.*; import java.util.Set; import java.util.regex.Pattern; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.document.mongodb.MongoTemplate; import org.springframework... 더보기 mongodb 다루기 2 1. 원하는 collection의 데이터 모두 지우기 > db.people.remove() > db.people.find() 2. 인덱스를 생성하면서 원하는 키를 동일한 문서에서 허용하고 싶지 않다면 > db.people.ensureIndex({"id":1,"unique":true}) 3. 데이터를 입력해보자. > db.people.insert({"id":6655, "name":"James", "gender":"male"}) > db.people.insert({"id":6797, "name":"Bond", "gender":"male"}) > db.people.insert({"id":6643, "name":"Cheryl", "gender":"female"}) > db.people.insert({"id":7.. 더보기 mongodb 다루기 1 { "_id" : ObjectId("4e1976aba5687c992a9f78ff"), "name" : "joe", "friends" : 32, "enemies" : 2 } 이러한 문서를 아래처럼 바꾸기 { "_id" : ObjectId("4e1976aba5687c992a9f78ff"), "relationships" : { "friends" : 32, "enemies" : 2 }, "username" : "joe" } 1. joe 라는 변수에 문서를 저장한다. > var joe = db.foo.findOne() 2. relationships 를 추가하고 > joe.relationships = {"friends":joe.friends,"enemies":joe.enemies} { "friends" : 32, .. 더보기 mongodb client 접속 간단한 접속 방법 C:\mongodb\bin>mongo --host awasoft.iptime.org usage: mongo [options] [db address] [file names (ending in .js)] db address can be: foo foo database on local machine 192.169.0.5/foo foo database on 192.168.0.5 machine 192.169.0.5:9999/foo foo database on 192.168.0.5 machine on port 9999 options: --shell run the shell after executing files --nodb don't connect to mongod on startup - no '.. 더보기 mongodb conf 파일 dbpath=C:\data\db logpath=C:\mongodb\logs\mongodb.log logappend=true verbose=true port=27017 #bind_ip=127.0.0.1 #fork=true #rest=true #auth=true #noauth=true 더보기 mongoDB 보안 관련 Tips http://dev.paran.com/2011/06/22/mongodb-security-tips-for-beginners/ => 감사합니다. 더보기 mongodb 제한자 사용하기 1. $inc 필요한 데이터를 넣어보자 > visit = {"url":"www.example.com", "pageviews":52} { "url" : "www.example.com", "pageviews" : 52 } > db.analytics.insert(visit) 확인하고 > db.analytics.findOne() { "_id" : ObjectId("4e058777080005633f97f766"), "url" : "www.example.com", "pageviews" : 52 } 업데이트 하고 > db.analytics.update({"url":"www.example.com"},{"$inc":{"pageviews":1}}) 다시 확인하면 1증가되어 있다. > db.analytics.findOne(.. 더보기 mongdb 쉘 활용 팁 > show dbs admin (empty) foobar 0.03125GB local (empty) test 0.03125GB > show collections blog system.indexes > show users > show profile db.system.profile is empty Use db.setProfilingLevel(2) will enable profiling Use db.system.profile.find() to show raw profile entries > db.help() DB methods: db.addUser(username, password[, readOnly=false]) db.auth(username, password) db.cloneDatabase(fromhost.. 더보기 mongodb 간단 명령어 1. 데이터베이스 선택 > use foobar switched to db foobar 2. 데이터베이스 확인 >db foobar 3. insert 우선 자바스크립트 객체로 지역변수인 post를 만들고 > post = {"title":"My Blog Post", "content":"Here's my blog post.", "date":new Date()} { "title" : "My Blog Post", "content" : "Here's my blog post.", "date" : ISODate("2011-06-25T06:01:32.381Z") } > db.blog.insert(post) insert 끝 완존 쉽다. 확인해 보자 > db.blog.find() { "_id" : ObjectId("4e057.. 더보기 이전 1 2 다음