25 lines
No EOL
647 B
TypeScript
25 lines
No EOL
647 B
TypeScript
import PocketBase from 'pocketbase';
|
||
|
||
const PB_URL = 'http://127.0.0.1:8090';
|
||
const pb = new PocketBase(PB_URL);
|
||
|
||
async function main() {
|
||
const posts = await pb.collection('posts').getList(1, 500);
|
||
|
||
let count = 0;
|
||
for (const post of posts.items) {
|
||
let content = post.content as string;
|
||
|
||
// Заменяем 2025 на 2026
|
||
if (content.includes('2025')) {
|
||
content = content.replace(/2025/g, '2026');
|
||
await pb.collection('posts').update(post.id, { content });
|
||
console.log(`✓ ${post.slug}: 2025 → 2026`);
|
||
count++;
|
||
}
|
||
}
|
||
|
||
console.log(`\nОбновлено постов: ${count}`);
|
||
}
|
||
|
||
main(); |