@@ -15,26 +15,28 @@ const Promise = require('bluebird');
1515
1616pluginManager . dbConnection ( "countly" ) . then ( ( db ) => {
1717 common . db = db ;
18+ const NEW_OID = common . db . ObjectID ( NEW_ID ) ;
19+ const OLD_OID = common . db . ObjectID ( OLD_ID ) ;
1820
1921 function changeOwner ( NEW_ID , OLD_ID , done ) {
2022 changeOwnerDashboard ( NEW_ID , OLD_ID , function ( ) {
21- common . db . collection ( "alerts" ) . update ( { createdBy : OLD_ID } , { $set : { createdBy : NEW_ID } } , function ( err , res ) {
23+ common . db . collection ( "alerts" ) . update ( { createdBy : OLD_OID } , { $set : { createdBy : NEW_OID } } , function ( err , res ) {
2224 console . log ( "alerts" , err , res && res . result ) ;
2325 common . db . collection ( "auth_tokens" ) . update ( { owner : OLD_ID } , { $set : { owner : NEW_ID } } , function ( err , res ) {
2426 console . log ( "auth_tokens" , err , res && res . result ) ;
2527 common . db . collection ( "calculated_metrics" ) . update ( { owner_id : OLD_ID } , { $set : { owner_id : NEW_ID } } , function ( err , res ) {
2628 console . log ( "calculated_metrics" , err , res && res . result ) ;
27- common . db . collection ( "concurrent_users_alerts" ) . update ( { created_by : OLD_ID } , { $set : { created_by : NEW_ID } } , function ( err , res ) {
29+ common . db . collection ( "concurrent_users_alerts" ) . update ( { created_by : OLD_OID } , { $set : { created_by : NEW_OID } } , function ( err , res ) {
2830 console . log ( "concurrent_users_alerts" , err , res && res . result ) ;
29- common . db . collection ( "data_migrations" ) . update ( { userid : OLD_ID } , { $set : { userid : NEW_ID } } , function ( err , res ) {
31+ common . db . collection ( "data_migrations" ) . update ( { userid : OLD_OID } , { $set : { userid : NEW_OID } } , function ( err , res ) {
3032 console . log ( "data_migrations" , err , res && res . result ) ;
3133 changeOwnerLongTasks ( NEW_ID , OLD_ID , function ( err , res ) {
32- console . log ( "messages" , err , res && res . result ) ;
33- common . db . collection ( "messages" ) . update ( { creator : OLD_ID } , { $set : { creator : NEW_ID } } , function ( err , res ) {
34+ console . log ( "messages" , err , res && res . result ) ; // "createdBy": { "$oid": "63442fa1ec94a1edb60f2453"}
35+ common . db . collection ( "messages" ) . update ( { "info.createdBy" : OLD_ID } , { $set : { "info.createdBy" : NEW_ID } } , function ( err , res ) {
3436 console . log ( "messages" , err , res && res . result ) ;
3537 common . db . collection ( "notes" ) . update ( { owner : OLD_ID } , { $set : { owner : NEW_ID } } , function ( err , res ) {
3638 console . log ( "notes" , err , res && res . result ) ;
37- common . db . collection ( "reports" ) . update ( { user : OLD_ID } , { $set : { user : NEW_ID } } , function ( err , res ) {
39+ common . db . collection ( "reports" ) . update ( { user : OLD_OID } , { $set : { user : NEW_OID } } , function ( err , res ) {
3840 console . log ( "reports" , err , res && res . result ) ;
3941 done ( ) ;
4042 } ) ;
0 commit comments