Add shortId handling for QR

Add renumerate script
Add Tasks
This commit is contained in:
mcarquigny
2025-06-27 15:35:31 +02:00
parent 6459dbd68c
commit a7225eb054
6 changed files with 95 additions and 5 deletions

31
scripts/renumerate.js Normal file
View File

@ -0,0 +1,31 @@
const PocketBase = require('pocketbase').default
// Initialize the PocketBase client
// const pb = new PocketBase('https://stock.hfsplay.fr')
const pb = new PocketBase('http://127.0.0.1:8090')
async function main () {
try {
// Authenticate as an admin
// await pb.admins.authWithPassword('gyoza@hfsplay.fr', 'gyozagyoza') // Replace with your admin credentials
await pb.collection('_superusers').authWithPassword('karkinge@gmail.com', 'k4rk1ng3*') // Replace with your admin credentials
console.log('connected !')
let stock = await pb.collection('stock').getFullList({
sort: 'created'
})
console.log('Stock items count:', stock.length)
for (let i = 0; i < stock.length; i++) {
const item = stock[i]
if (!item) continue
// Update the item with a new ID
const updatedItem = await pb.collection('stock').update(item.id, {
short_id: i + 1 // Adjust the ID as needed
})
console.log(`Updated item ${item.id} to new ID ${updatedItem.id}`)
}
} catch (error) {
console.error('Error:', error)
}
}
main()