File tree Expand file tree Collapse file tree 2 files changed +50
-24
lines changed
Expand file tree Collapse file tree 2 files changed +50
-24
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * Removes the "media" widget with mediaId "dM3L-CVOXLGv3XxsnRUd_D3SD-S5hCkuTzTx432L"
3+ * from page.layout and page.draftLayout arrays.
4+ *
5+ * Usage: DB_CONNECTION_STRING=<mongodb-connection-string> node 22-02-26_22-42-remove-media-widget-from-homepage.js
6+ */
7+ import mongoose from "mongoose" ;
8+
9+ const DB_CONNECTION_STRING = process . env . DB_CONNECTION_STRING ;
10+ if ( ! DB_CONNECTION_STRING ) {
11+ throw new Error ( "DB_CONNECTION_STRING is not set" ) ;
12+ }
13+
14+ ( async ( ) => {
15+ try {
16+ await mongoose . connect ( DB_CONNECTION_STRING , {
17+ useNewUrlParser : true ,
18+ useUnifiedTopology : true ,
19+ } ) ;
20+
21+ const db = mongoose . connection . db ;
22+ if ( ! db ) {
23+ throw new Error ( "Could not connect to database" ) ;
24+ }
25+
26+ const result = await db . collection ( "pages" ) . updateMany (
27+ { } ,
28+ {
29+ $pull : {
30+ layout : {
31+ name : "media" ,
32+ "settings.media.mediaId" :
33+ "dM3L-CVOXLGv3XxsnRUd_D3SD-S5hCkuTzTx432L" ,
34+ } ,
35+ draftLayout : {
36+ name : "media" ,
37+ "settings.media.mediaId" :
38+ "dM3L-CVOXLGv3XxsnRUd_D3SD-S5hCkuTzTx432L" ,
39+ } ,
40+ } ,
41+ } ,
42+ ) ;
43+
44+ console . log (
45+ `✅ Modified ${ result . modifiedCount } page(s). Removed media widget from layout and draftLayout.` ,
46+ ) ;
47+ } finally {
48+ await mongoose . connection . close ( ) ;
49+ }
50+ } ) ( ) ;
Original file line number Diff line number Diff line change @@ -182,30 +182,6 @@ export const homePageTemplate = [
182182 // backgroundColor: "#f4f4f5",
183183 } ,
184184 } ,
185- {
186- widgetId : generateUniqueId ( ) ,
187- name : "media" ,
188- deleteable : true ,
189- shared : false ,
190- settings : {
191- pageId : "homepage" ,
192- type : "site" ,
193- entityId : "demo" ,
194- media : {
195- mediaId : "dM3L-CVOXLGv3XxsnRUd_D3SD-S5hCkuTzTx432L" ,
196- originalFileName : "Basics.jpg" ,
197- mimeType : "image/jpeg" ,
198- size : 113901 ,
199- access : "public" ,
200- file : "https://cdn.medialit.cloud/medialit-service/p/dM3L-CVOXLGv3XxsnRUd_D3SD-S5hCkuTzTx432L/main.jpg" ,
201- thumbnail :
202- "https://cdn.medialit.cloud/medialit-service/p/dM3L-CVOXLGv3XxsnRUd_D3SD-S5hCkuTzTx432L/thumb.webp" ,
203- caption : "" ,
204- } ,
205- mediaRadius : 2 ,
206- // backgroundColor: "#171127",
207- } ,
208- } ,
209185 {
210186 widgetId : generateUniqueId ( ) ,
211187 name : "faq" ,
You can’t perform that action at this time.
0 commit comments