feat: add standalone script example
This commit is contained in:
parent
0d1087d5bc
commit
ec95e415c6
@ -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"
|
||||||
|
17
src/scripts/standalone-script.ts
Normal file
17
src/scripts/standalone-script.ts
Normal 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)
|
Loading…
Reference in New Issue
Block a user