Open toppy-luna opened 4 years ago
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
brew tap mongodb/brew
brew install mongodb-community@4.2
mongod --version
db version v4.2.1
git version: edf6d45851c0b9ee15548f0f847df141764a317e
allocator: system
modules: none
build environment:
distarch: x86_64
target_arch: x86_64
mongod --config /usr/local/etc/mongod.conf --fork
about to fork child process, waiting until server is ready for connections.
forked process: 13546
child process started successfully, parent exiting
ps -ef | grep mongod
501 13546 1 0 2:28PM ?? 0:01.06 mongod --config /usr/local/etc/mongod.conf --fork
501 13555 553 0 2:28PM ttys001 0:00.00 grep mongod
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/#connect-and-use-mongodb
mongo --host localhost --port 27017
# Create
db.inventory.insertOne(
{ item: "canvas", qty: 100, tags: ["cotton"], size: { h: 28, w: 35.5, uom: "cm" } }
)
db.inventory.insertMany([
{ item: "journal", qty: 25, tags: ["blank", "red"], size: { h: 14, w: 21, uom: "cm" } },
{ item: "mat", qty: 85, tags: ["gray"], size: { h: 27.9, w: 35.5, uom: "cm" } },
{ item: "mousepad", qty: 25, tags: ["gel", "blue"], size: { h: 19, w: 22.85, uom: "cm" } }
])
# Read
db.inventory.find( {} )
db.inventory.find( { item: "canvas" } )
# Update
db.inventory.updateOne(
{ item: "journal" },
{
$set: { "size.uom": "in", qty: 26 },
$currentDate: { lastModified: true }
}
)
# Delete
db.inventory.deleteMany({ "size.uom" : "in" })
db.inventory.deleteMany({})
docker run --rm --publish 27017:27017 --name mongodb --detach mongo
mongo --host localhost --port 27017
docker stop
http://mongodb.github.io/node-mongodb-native/3.1/quick-start/quick-start/
npm install mongodb @types/mongodb
npm install mongoose @types/mongoose
15 にてRDBMS(PostgreSQL)を使ってデータを永続化したが、データ規模が最小であるため、また使用したことがない技術を使ってみる観点でNoSQL(mongoDB)を使用してみる。
Action