Javascript function to save new fields from existing fields (migration) in mongodb collection -
Javascript function to save new fields from existing fields (migration) in mongodb collection -
we have design alter in application accommodate few new requirements. design alter forced migrate 1 of mongodb collection, instead of having individual fields, have create derived json string field existing fields.
the migration process invoked end-user doing action in ui (like saving change). 1 action might update few thousands of documents. write javascript code executed on server side, can avoid loading many records application.
but issue running is, cannot phone call java script function using eval collection sharded. , other alternative cannot consider create collection un-sharded migration has happen on live system.
please help if know of alternate approach.
example migration : exampledoc (collection) has fields a1, a2, b1 , b2. migration create new fields called fieldjson : { : "", b : ""}. here , b derived existing fields a1, a2, b1 , b2.
ok, understand
you want create new field same collection sharded; the content of new field generated existing fields; you don't want fetch these existing fields database application handling perhaps because of big volume; you can't invokeeval
database command because it's sharded collection; you can't un-shard current collection. then, possible fulfill intent through mapreduce
?
{out:{merge:<collectionname>, sharded:true}}
. mongodb spring-data-mongodb mongodb-java
Comments
Post a Comment