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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const { User } = require('../../app/src/models/User')
|
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-01 05:53:36 -04:00
|
|
|
if (!module.parent) {
|
|
|
|
// we are in the root module, which means that we're running as a script
|
2019-10-01 07:30:10 -04:00
|
|
|
runScript()
|
|
|
|
.then(() => process.exit())
|
|
|
|
.catch(err => {
|
|
|
|
console.error(err)
|
|
|
|
process.exit(1)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = runScript
|