mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
b69ff9417a
Revert "Convert migration scripts to ESM" GitOrigin-RevId: ca9ddda6ddee8964f72797d3b653ef9cee6a7a49
28 lines
790 B
JavaScript
28 lines
790 B
JavaScript
/* 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')
|
|
// const somePackage = require('some-package')
|
|
|
|
const runScript = async () => {
|
|
const user = await User.findOne({}, { first_name: 1 }).exec()
|
|
const name = user ? user.first_name : 'World'
|
|
console.log(`Hello ${name}!`)
|
|
}
|
|
|
|
if (!module.parent) {
|
|
// we are in the root module, which means that we're running as a script
|
|
runScript()
|
|
.then(() => process.exit())
|
|
.catch(err => {
|
|
console.error(err)
|
|
process.exit(1)
|
|
})
|
|
}
|
|
|
|
module.exports = runScript
|