Add shortId handling for QR
Add renumerate script Add Tasks
This commit is contained in:
31
scripts/renumerate.js
Normal file
31
scripts/renumerate.js
Normal 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()
|
Reference in New Issue
Block a user