2017-09-25 60 views
0

因此,不是直接使用mongo shell,而是決定創建一個json文件然後將其導入monngodb,但是在這個過程中發生了一些奇怪的事情。我的繼承人代碼:使用mongoimport不能正確保存數據

mongoimport --db test_poke --collection測試--type JSON --file pokeapi.json --jsonArray

2017-09-24T23:45:44.017-0400連接到:本地主機 2017-09-24T23:45:44.624-0400進口4號文件

> show dbs 
admin  0.000GB 
anime  0.000GB 
api   0.000GB 
exampleDb 0.000GB 
local  0.000GB 
myDB  0.000GB 
pokedex  0.000GB 
superheros 0.000GB 
test_poke 0.000GB 
users  0.000GB 
yUser  0.000GB 
> use test_poke 
switched to db test_poke 
> db.test_poke.find() 
> db.test_poke.find({}) 

// JSON數據

{ 
    "name": "pikachu", 
    "size": "small", 
    "element_type": "electric" 
    }, 
    { 
    "name": "squirtle", 
    "size": "small", 
    "element_type": "water" 

    }, 
    { 
    "name": "charmander", 
    "size": "small", 
    "element_type": "fire" 
    }, 
    { 
    "name": "bulbasoor", 
    "size": "small", 
    "element_type": "earth" 
    } 

沒有數據發現我猜是因爲什麼都不會返回,但使用任何Ë查看CRUD的作品並顯示結果。此外,我閱讀文檔,並確保遵循他們的指示,但沒有去。有人能幫忙嗎?使用mongodb的3.4.7版本。

+1

'db.testing.find()'? – Veeram

+0

我試過了,沒有顯示,以及 –

回答

1

您的館藏名爲testing,位於test_poke數據庫中。正如評論所示,你的查詢是錯誤的,應該是

db.testing.find() 
+0

我切換到測試以及它沒有工作。意味着在我離開工作之前補充一點 –

相關問題