Open3
KVS@memo@dev
> db.collection.insertOne({name: '<任意の文字列>', age: 任意の数値, breed: '<任意の種別>', catFriendly: 論理演算子})
> {
acknowledged: true,
insertedId: ObjectId('<自動的に生成させるid>')
}
> show collections
> db.collection.find()
> [
{
_id: ObjectId('<自動的に生成されるid>'),
name: '<任意の文字列>',
age: <任意の数値>,
breed: '<任意の種別>',
catFriendly: 論理演算子
}
]
> db.collection.insert([{name: '<任意の文字列>',breed: '<任意の種別>', age: <任意の数値>,catFriendly: 論理演算子},{name: '<任意の文字列>',...--省略--}])
DeprecationWarning: Collection.insert() is deprecated. Use insertOne, insertMany, or bulkWrite.
{
acknowledged: true,
insertedIds: {
'0': ObjectId('<自動的に生成させるid>'),
'1': ObjectId('<自動的に生成させるid>')
}
}
> show dbs
admin 40.00 KiB
animalShelter 72.00 KiB
config 96.00 KiB
local 40.00 KiB
------更新前-----
{
_id: ObjectId('-----'),
name: 'ハチ',
breed: 'golden',
age: 10,
catFriendly: false
}
-----更新コマンド-----
db.dogs.updateOne({name: 'ハチ'}, {$set: {age: 11}})
{
acknowledged: true,
insertedId: null,
matchedCount: 1,
modifiedCount: 1,
upsertedCount: 0
}
-----検索-----
db.dogs.find({name : 'ハチ'})
-----更新内容-----
[
{
_id: ObjectId('--------'),
name: 'ハチ',
breed: 'golden',
age: 11,
catFriendly: false
}
]