2016-10-08 126 views
0

我有一個集合(CollectionA)。在這個集合中有 有更多實驗的數據。MongoDB將數據拆分爲更多集合

我想每個實驗創建一個集合: Collection1,Collection2 ...

有一個模式?而不會丟失數據?

ps。我可以MongoDB的接口使用PHP


添加信息:

我有實驗的很多很多數據(experimentA,ExperimentB,...)的集合。

我想要將這個集合分成更多的集合,每個實驗集合一個。

(一種分區)


Collection NAME = testCollection 
在此集合

有 「實驗」 場 (前ExperimentA,ExperimentB,...。)

COLLECTION輸出所需:

testCollection_ExperimentA 

testCollection_ExperimentB 

需要更多信息?

回答

1

MongoDB使易於使用拆分方法。

在運行下面的命令:

db.runCommand({ split : "db.collectionName", find : { 'experimentName' : "A" } }) 

分割命令標識在db.collectionName塊。然後該命令將其分成兩個塊。 您可以根據需要多次使用。

您可以閱讀完整的文檔here

+0

感謝您的回答。這個命令用數據創建一個新的Collection(experimentName = A)? – mydb