Monday 24 June 2019

process.exit() noobi question

Hi,​I want to push some data in a mongoDB collection with a simple node script. I'm working with await and async statements.This code work so far. What bothers me is the process.exit().If I remove the exit-statement the script never ends. Is this normal?Do I really need the statement to get my shell back?const mongoose = require('mongoose');const Device = require('./models/device');mongoose.connect('mongodb://mongo/test',{useNewUrlParser: true}).then(async () => {const device = await Device.create({"id": "fba1e835-5b14-4940-b56d-cbfsdbe3","serial": "unknown",});console.log(\Device created`);`process.exit();}).catch(err => {console.error('Could not connect to MongoDB...', err);});

Submitted June 24, 2019 at 03:48PM by 23hurra

No comments:

Post a Comment