InsertDummyData.js
/*
MongoDBのシェルではJavaScriptが動きます。
以下を必要に応じ変更してコピペすればダミーデータが作成できます。
初期投入件数は10件です。
*/
for (var i=0; i<10; i++) {
db.test.insert(
{
"id" : "id" + i,
"name" : i + "郎",
"comment" : "私は" + i + "郎です。" ,
"created" : new Date(),
"updated" : new Date(),
}
);
}
MongoDBのシェルにコピペして実行。
> for (var i=0; i<10; i++) {
... db.test.insert(
... {
... "id" : "id" + i,
... "name" : i + "郎",
... "comment" : "私は" + i + "郎です。" ,
... "created" : new Date(),
... "updated" : new Date(),
... }
... );
... }
findで結果を見ると以下のようになる。
> db.test.find()
{ "_id" : ObjectId("5630e5466ed4cd5f7dbace78"), "id" : "id0", "name" : "0郎", "comment" : "私は0郎です。", "created" : ISODate("2015-10-28T15:09:58.479Z"), "updated" : ISODate("2015-10-28T15:09:58.479Z") }
{ "_id" : ObjectId("5630e5466ed4cd5f7dbace79"), "id" : "id1", "name" : "1郎", "comment" : "私は1郎です。", "created" : ISODate("2015-10-28T15:09:58.485Z"), "updated" : ISODate("2015-10-28T15:09:58.485Z") }
{ "_id" : ObjectId("5630e5466ed4cd5f7dbace7a"), "id" : "id2", "name" : "2郎", "comment" : "私は2郎です。", "created" : ISODate("2015-10-28T15:09:58.490Z"), "updated" : ISODate("2015-10-28T15:09:58.490Z") }
{ "_id" : ObjectId("5630e5466ed4cd5f7dbace7b"), "id" : "id3", "name" : "3郎", "comment" : "私は3郎です。", "created" : ISODate("2015-10-28T15:09:58.491Z"), "updated" : ISODate("2015-10-28T15:09:58.491Z") }
{ "_id" : ObjectId("5630e5466ed4cd5f7dbace7c"), "id" : "id4", "name" : "4郎", "comment" : "私は4郎です。", "created" : ISODate("2015-10-28T15:09:58.492Z"), "updated" : ISODate("2015-10-28T15:09:58.492Z") }
{ "_id" : ObjectId("5630e5466ed4cd5f7dbace7d"), "id" : "id5", "name" : "5郎", "comment" : "私は5郎です。", "created" : ISODate("2015-10-28T15:09:58.492Z"), "updated" : ISODate("2015-10-28T15:09:58.492Z") }
{ "_id" : ObjectId("5630e5466ed4cd5f7dbace7e"), "id" : "id6", "name" : "6郎", "comment" : "私は6郎です。", "created" : ISODate("2015-10-28T15:09:58.493Z"), "updated" : ISODate("2015-10-28T15:09:58.493Z") }
{ "_id" : ObjectId("5630e5466ed4cd5f7dbace7f"), "id" : "id7", "name" : "7郎", "comment" : "私は7郎です。", "created" : ISODate("2015-10-28T15:09:58.493Z"), "updated" : ISODate("2015-10-28T15:09:58.493Z") }
{ "_id" : ObjectId("5630e5466ed4cd5f7dbace80"), "id" : "id8", "name" : "8郎", "comment" : "私は8郎です。", "created" : ISODate("2015-10-28T15:09:58.494Z"), "updated" : ISODate("2015-10-28T15:09:58.494Z") }
{ "_id" : ObjectId("5630e5466ed4cd5f7dbace81"), "id" : "id9", "name" : "9郎", "comment" : "私は9郎です。", "created" : ISODate("2015-10-28T15:09:58.495Z"), "updated" : ISODate("2015-10-28T15:09:58.495Z") }