2019-10-01 07:30:10 -04:00
|
|
|
/* subscription.freeTrialExpiresAt
|
|
|
|
* Example script for a migration:
|
|
|
|
*
|
|
|
|
* This script demonstrates how to write a script that is runnable either via
|
|
|
|
* the CLI, or via a migration. The related migration is `script_example`
|
|
|
|
* in the migrations directory.
|
|
|
|
*/
|
|
|
|
|
2024-10-22 04:21:39 -04:00
|
|
|
import { User } from '../../app/src/models/User.js'
|
2024-11-04 04:09:11 -05:00
|
|
|
import { fileURLToPath } from 'node:url'
|
2024-10-22 04:21:39 -04:00
|
|
|
|
2019-10-16 06:10:54 -04:00
|
|
|
// const somePackage = require('some-package')
|
2019-10-01 07:30:10 -04:00
|
|
|
|
|
|
|
const runScript = async () => {
|
|
|
|
const user = await User.findOne({}, { first_name: 1 }).exec()
|
|
|
|
const name = user ? user.first_name : 'World'
|
2019-10-16 06:10:54 -04:00
|
|
|
console.log(`Hello ${name}!`)
|
2019-10-01 07:30:10 -04:00
|
|
|
}
|
|
|
|
|
2024-10-22 04:21:39 -04:00
|
|
|
if (fileURLToPath(import.meta.url) === process.argv[1]) {
|
|
|
|
try {
|
|
|
|
await runScript()
|
|
|
|
process.exit()
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error)
|
|
|
|
process.exit(1)
|
|
|
|
}
|
2019-10-01 07:30:10 -04:00
|
|
|
}
|
|
|
|
|
2024-10-22 04:21:39 -04:00
|
|
|
export default runScript
|