mongodb - change order of specific mongo records -
in mongodb records this
{ "_id" : objectid("5191fc1206610430cd000004"), "ancestry" : null, "name" : "root" } { "_id" : objectid("5191fc1306610430cd000005"), "ancestry" : null, "name" : "root1"} { "_id" : objectid("5191fc2706610430cd000006"), "ancestry" : null, "name" : "root2"} { "_id" : objectid("5191fc2806610430cd000007"), "ancestry" : null, "name" : "root3"} i want change order of records this
{ "_id" : objectid("5191fc2706610430cd000006"), "ancestry" : null, "name" : "root2"} { "_id" : objectid("5191fc1206610430cd000004"), "ancestry" : null, "name" : "root" } { "_id" : objectid("5191fc1306610430cd000005"), "ancestry" : null, "name" : "root1"} { "_id" : objectid("5191fc2806610430cd000007"), "ancestry" : null, "name" : "root3"} and have following information node move
{ "_id" : objectid("5191fc2706610430cd000006"), "ancestry" : null, "name" : "root2"} move before node
{ "_id" : objectid("5191fc1206610430cd000004"), "ancestry" : null, "name" : "root" } how can this??
you cannot that. cannot change order of records. sorted objectid(almost). if want sort based on parameter, put objects , sort parameter.
Comments
Post a Comment