feat: add standalone script example

This commit is contained in:
Elliot DeNolf 2024-04-06 13:47:04 -04:00
parent 0d1087d5bc
commit ec95e415c6
2 changed files with 19 additions and 1 deletions

View File

@ -9,7 +9,8 @@
"build": "cross-env NODE_OPTIONS=--no-deprecation next build", "build": "cross-env NODE_OPTIONS=--no-deprecation next build",
"payload": "cross-env NODE_OPTIONS=--no-deprecation payload", "payload": "cross-env NODE_OPTIONS=--no-deprecation payload",
"start": "cross-env NODE_OPTIONS=--no-deprecation next start", "start": "cross-env NODE_OPTIONS=--no-deprecation next start",
"lint": "cross-env NODE_OPTIONS=--no-deprecation next lint" "lint": "cross-env NODE_OPTIONS=--no-deprecation next lint",
"standalone-script": "tsx ./src/scripts/standalone-script.ts"
}, },
"engines": { "engines": {
"node": ">=18.19.0" "node": ">=18.19.0"

View File

@ -0,0 +1,17 @@
import { getPayload } from 'payload'
import { importConfig } from 'payload/node'
import 'dotenv/config'
async function run() {
const awaitedConfig = await importConfig('../../payload.config.ts')
const payload = await getPayload({ config: awaitedConfig })
const pages = await payload.find({
collection: 'pages',
})
console.log(pages)
process.exit(0)
}
run().catch(console.error)