Because the preliminary design is not week-long, the primary key _ id is objectid, so it is not convenient to update and maintain. It is too troublesome to modify it later.
// A duplicate record will be created. "city" and "category" are the unique indexes in the collection.
DB. categorycount. Find ({"_ id": {"$ type": 7}). foreach (function (x ){
X. _ id = "" + X. City + X. category;
DB. categorycount. Save (X );
});
// Through the above call, you have copied a record. The primary key is not of the string type. The record whose old objectid is the primary key will be deleted below
DB. categorycount. Remove ({"_ id": {"$ type": 7 }});
// The type value corresponding to the type is
| Type |
Value |
| Double |
1 |
| String |
2 |
| Object |
3 |
| Array |
4 |
| Binary data |
5 |
| Object ID |
7 |
| Boolean |
8 |
| Date |
9 |
| Null |
10 |
| Regular Expression |
11 |
| JavaScript code |
13 |
| Symbol |
14 |
| JavaScript code with scope |
15 |
| 32-bit integer |
16 |
| Timestamp |
17 |
| 64-bit integer |
18 |
| Min key |
255 * |
| Max key |
127 |