-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdate_sub.js
More file actions
29 lines (28 loc) · 893 Bytes
/
update_sub.js
File metadata and controls
29 lines (28 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const { MongoClient } = require('mongodb');
const uri = "mongodb+srv://lahorivenkatesh709:p0SkcBwHo67ghvMW@cluster0.y8ucl.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0";
async function run() {
const client = new MongoClient(uri);
try {
await client.connect();
const db = client.db('pebly-database');
const result = await db.collection('subscriptions').updateMany(
{ userId: '69989e0b7edbb8598f05e7f8' },
{
$set: {
planType: 'PRO',
isActive: true,
status: 'ACTIVE',
aiPagesGenerated: 0,
aiFieldsGenerated: 0
}
},
{ upsert: true }
);
console.log(`Updated subscriptions. Matched = ${result.matchedCount}, Modified = ${result.modifiedCount}, UpsertedId = ${result.upsertedId}`);
} catch (e) {
console.error(e);
} finally {
await client.close();
}
}
run();