Created
April 15, 2014 12:43
-
-
Save akm/10729459 to your computer and use it in GitHub Desktop.
MongoDB-2.6.0で変わったensureIndexの振る舞い ref: http://qiita.com/akm/items/799f2c7a6a6697f25127
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % mongo test | |
| MongoDB shell version: 2.4.6 | |
| connecting to: test | |
| > | |
| > db.t1.drop(); | |
| false | |
| > db.createCollection("t1", {}); | |
| { "ok" : 1 } | |
| > db.t1.ensureIndex({f1: 1}, {uniq: true}); | |
| > db.t1.ensureIndex({f1: 1}, {}); | |
| > | |
| > db.t1.dropIndex({f1: 1}) | |
| { "nIndexesWas" : 2, "ok" : 1 } | |
| > db.t1.ensureIndex({f1: 1}, {}); | |
| > |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % mongo test | |
| MongoDB shell version: 2.4.6 | |
| connecting to: test | |
| > | |
| > db.t1.drop(); | |
| true | |
| > db.createCollection("t1", {}); | |
| { "ok" : 1 } | |
| > db.t1.ensureIndex({f1: 1}, {uniq: true}); | |
| > db.t1.ensureIndex({f1: 1}, {}); | |
| { | |
| "connectionId" : 1, | |
| "err" : "Index with name: f1_1 already exists with different options", | |
| "code" : 17427, | |
| "n" : 0, | |
| "ok" : 1 | |
| } | |
| > | |
| > db.t1.dropIndex({f1: 1}) | |
| { "nIndexesWas" : 2, "ok" : 1 } | |
| > db.t1.ensureIndex({f1: 1}, {}); | |
| > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment