Last active
April 2, 2020 23:23
-
-
Save advorak/c3a741824d009dc57ff32f50437a5af1 to your computer and use it in GitHub Desktop.
Revisions
-
advorak revised this gist
Apr 2, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,4 +7,4 @@ db.episodes.updateMany({},[{$set: {created_at: "$data.date_gmt"}}]) db.episodes.updateMany({},[{$set: {created_at: (new Date("$data.date_gmt" + "Z"))}}]) // My goal is to set to: {created_at: ISODate("2020-03-30T10:00:08Z")} db.episodes.updateMany({},[{$set: {created_at: {$dateFromString: {dateString:("$data.date_gmt")}}}}]) -
advorak renamed this gist
Apr 2, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
advorak created this gist
Apr 2, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ // db.episodes.findOne({}) { "_id" : ObjectId("5e8563a07aeda6f729a56e33"), "data" : { "date_gmt" : "2020-03-30T10:00:08" } } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ // I want to take the field data.date_gmt and convert it from a text object to a new Date() object. // This one sets {created_at: "2020-03-30T10:00:08Z"} db.episodes.updateMany({},[{$set: {created_at: "$data.date_gmt"}}]) // This one sets {created_at: ISODate("1970-01-01T00:00:00Z")} db.episodes.updateMany({},[{$set: {created_at: (new Date("$data.date_gmt" + "Z"))}}]) // My goal is to set to: {created_at: ISODate("2020-03-30T10:00:08Z")} // What am i doing wrong? :-) Thanks!