Node.js Nodejs:在fs.readFile中使用async/await与在googlesheet中使用async/await

Node.js Nodejs:在fs.readFile中使用async/await与在googlesheet中使用async/await,node.js,json,mongodb,express,async-await,Node.js,Json,Mongodb,Express,Async Await,我有数据要从Google Sheets和MySQL迁移到MongoDB。为了让Google Sheets读取工作表id和行,然后我使用Mongoose对数据进行一些处理并将它们插入MongoDB,它使用等待步骤按照顺序插入对象 但我在使用Mysql时遇到了一些问题,我将数据存储在一个json文件(json对象数组)中,当我尝试读取该文件并开始在DB中插入等待步骤时,它会忽略它们,下面是代码: fs.readFile('mysql.json', (err, data) => { i

我有数据要从Google Sheets和MySQL迁移到MongoDB。为了让Google Sheets读取工作表id和行,然后我使用Mongoose对数据进行一些处理并将它们插入MongoDB,它使用等待步骤按照顺序插入对象

但我在使用Mysql时遇到了一些问题,我将数据存储在一个json文件(json对象数组)中,当我尝试读取该文件并开始在DB中插入等待步骤时,它会忽略它们,下面是代码:

 fs.readFile('mysql.json', (err, data) => {
    if (err) throw err;
    let results = JSON.parse(data);
    results.forEach(function (row, index) {


        const book = new Book({
            name  : row.NAME
        });

        book.save().then(async function (resBook) {
            try {

             const product = new Product({
                    "BOOKID" : resBook.ID
             })

                let resProduct = await product.save();

                try {

                    const object = new Object({
                        "PRODUCTID": resProduct.ID
                    });

                } catch (error) {
                    console.log("Error ")
                }

            } catch (err) {
                console.log('err' + err);
            }
        })

    });
});
当我启动应用程序时,它会直接转到[nodemon]clean exit

如果我尝试像这样简单的方法来显示数据,它是有效的,但当我添加以下步骤时,它就不起作用了:

    if (err) throw err;
    let results = JSON.parse(data);
    results.forEach(function (row, index) {
        console.log(row)
    });
});
在GoogleSheets代码中,我将我的步骤放在listMajors函数中,它按预期工作

你能帮我解决json文件方法的问题吗

谢谢