Created
July 1, 2024 22:43
-
-
Save ProfAvery/e224591a2373439504e8b4336ce100f6 to your computer and use it in GitHub Desktop.
PocketBase item population script - Summer 2024 AMSE Bootcamp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PocketBase from 'pocketbase'; | |
const pb = new PocketBase('http://127.0.0.1:8090'); | |
const data = [ | |
{ | |
itemId: 'coffee', | |
imageId: 'coffee', | |
title: 'Coffee', | |
price: 0.99, | |
description: '', | |
salePrice: 0, | |
}, | |
{ | |
itemId: 'cookie', | |
imageId: 'cookie', | |
title: 'Cookie', | |
price: 1, | |
description: 'May contain nuts.', | |
salePrice: 0.50, | |
}, | |
{ | |
itemId: 'croissant', | |
imageId: 'croissant', | |
title: 'Croissant', | |
price: 2.50, | |
}, | |
{ | |
itemId: 'cupcake', | |
imageId: 'cupcake', | |
title: 'Cupcake', | |
price: 3, | |
}, | |
{ | |
itemId: 'french-press', | |
imageId: 'french-press', | |
title: 'French Press', | |
price: 1.75, | |
}, | |
{ | |
itemId: 'iced-coffee', | |
imageId: 'iced-coffee', | |
title: 'Iced Coffee', | |
price: 1.25, | |
}, | |
{ | |
itemId: 'latte', | |
imageId: 'latte', | |
title: 'Latte', | |
price: 2, | |
}, | |
{ | |
itemId: 'milk', | |
imageId: 'milk', | |
title: 'Milk', | |
price: 0.50, | |
}, | |
{ | |
itemId: 'sandwich', | |
imageId: 'sandwich', | |
title: 'Sandwich', | |
price: 6, | |
}, | |
{ | |
itemId: 'tea', | |
imageId: 'tea', | |
title: 'Tea', | |
price: 1.50, | |
}, | |
]; | |
for (const item of data) { | |
await pb.collection('items').create(item); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment