34 lines
No EOL
1 KiB
TypeScript
34 lines
No EOL
1 KiB
TypeScript
import PocketBase from 'pocketbase';
|
||
import fs from 'fs';
|
||
|
||
const PB_URL = 'http://127.0.0.1:8090';
|
||
const pb = new PocketBase(PB_URL);
|
||
|
||
async function exportPosts() {
|
||
console.log('📤 Экспорт постов в JSON\n');
|
||
|
||
const posts = await pb.collection('posts').getList(1, 500);
|
||
|
||
const exportData = posts.items.map(post => ({
|
||
id: post.id,
|
||
title: post.title,
|
||
slug: post.slug,
|
||
content: post.content,
|
||
description: post.description,
|
||
category: post.category,
|
||
categoryColor: post.categoryColor,
|
||
image: post.image,
|
||
date: post.date,
|
||
author: post.author,
|
||
readTime: post.readTime,
|
||
views: post.views,
|
||
draft: post.draft,
|
||
}));
|
||
|
||
fs.writeFileSync('./posts-export.json', JSON.stringify(exportData, null, 2), 'utf-8');
|
||
|
||
console.log(`Экспортировано ${exportData.length} постов в posts-export.json`);
|
||
console.log('\nТеперь нужно импортировать через админ-панель: https://avt-back.ru/_/');
|
||
}
|
||
|
||
exportPosts(); |