You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.1 KiB
36 lines
1.1 KiB
const PocketBase = require('pocketbase').default
|
|
|
|
// Initialize the PocketBase client
|
|
const pb = new PocketBase('http://127.0.0.1:8090')
|
|
|
|
async function main () {
|
|
try {
|
|
// Authenticate as an admin
|
|
await pb.admins.authWithPassword('karkinge@gmail.com', 'PBk4rk1ng3*') // Replace with your admin credentials
|
|
|
|
// Parse JSON file with categories
|
|
const data = require('../../gyoza/database_backups/20250320.json')
|
|
console.log('Data ok:', data.categories)
|
|
|
|
// Perform some operations, e.g., create a new record in the 'categories' collection
|
|
for (let stock of data.stock) {
|
|
if (!stock) continue
|
|
const newStock = await pb.collection('stock').create({
|
|
available: stock.available,
|
|
comment: stock.comment,
|
|
deleted: stock.deleted,
|
|
name: stock.name,
|
|
owner: stock.owner,
|
|
ref: stock.ref,
|
|
state: stock.state,
|
|
type: stock.type,
|
|
working: stock.working
|
|
})
|
|
console.log('New stock created:', newStock)
|
|
}
|
|
} catch (error) {
|
|
console.error('Error:', error)
|
|
}
|
|
}
|
|
|
|
main()
|
|
|