什么数据库与Node.js最兼容?

Dza*_*nvu 1 javascript node.js

目前,我正在使用Node.js构建一个网站.我熟悉MySQL.但是我发现有人说Node.js的MySQL模块有问题并且与Node.js不兼容.所以我想知道任何与Node.js最兼容的数据库.mongodb是个不错的选择吗?

提前致谢.

小智 6

我每次都在使用MongoDB和我的Node.js应用程序.这很容易和优雅,因为Mongo具有与应用程序其他部分类似的语法.
例如,此方法检索所选用户的一些条目:

exports.entries = function (req, res) {
    var user_id = parseInt(req.params.user_id);

    db.collection('entries', function(err, collection) {
        collection.find({user_id: user_id}).toArray(
            function(err, entries) {
                res.json({
                    entries: entries
                });
            }
        );
    });
};
Run Code Online (Sandbox Code Playgroud)

此外,MongoDB驱动程序是用纯JavaScript编写的,并为MongoDB提供了一个本机异步Node.js接口,使其非常快.