将Mongodb嵌入Electron [英] Embed Mongodb with Electron

查看:445
本文介绍了将Mongodb嵌入Electron的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将MongoDB源代码保留在电子源代码中,并使用以下命令运行MongoDB:

I am keeping MongoDB source code inside electron source code and running MongoDB using this command :

const app = require('electron').app;
const child_process = require('child_process');
const dbInstanceDir = app.getAppPath();
const startMongo = dbInstanceDir + mongodb/bin/mongod --dbpath mydbpath --port 27017 --logpath mylogfile

child_process.exec(startMongo, (error, stdout, stderr) => {
});

上面的命令在开发时有效,但在捆绑后却不起作用。我正在使用电子助剂制造束。 MongoDB源代码位于根级别。

Above command is working while development but it not working after bundling. I am using electron builder to make bundle. MongoDB source code is at root level.

推荐答案

据我所知,您不能将MongoDB与Electron打包,必须将其单独安装。从此站点引用: https://www.techiediaries.com/electron-data-persistence/

As far as I know, you cannot package MongoDB with Electron, it must be installed separately. Quoting from this site: https://www.techiediaries.com/electron-data-persistence/


使用MongoDB的利弊

对于将MongoDB与Electron应用程序结合使用的优点:

For the pros of using MongoDB with Electron apps:


  • 适用于所有Electron支持的平台,例如Windows,Linux
    和MAC。因此,它不限制Electron的跨平台功能。

  • Available for all Electron suppored platforms such as Windows, Linux and MAC. So it doesn't limit the cross platform feature of Electron.

可以轻松安装并与Electron集成。

Can be installed and integrated easily with Electron.

还有一些缺点:


  • 不能与Electron捆绑在一起,因此最终用户需要与应用程序分开安装

  • 小应用程序的过度杀伤。

相反,可能我建议使用NeDB- https://github.com/louischatriot/nedb

Instead, might I suggest using NeDB - https://github.com/louischatriot/nedb

NeDB使用MongoDB API的一个子集,因此您无需为读写进行大量更改。如果您继续阅读我上面发布的链接,那么它也涵盖了在Electron应用程序中使用NeDB。

NeDB uses a subset of the MongoDB API so you shouldn't need to alter much code for reading and writing. If you continue reading the link I posted above, it also covers using NeDB within an Electron app.

还有很多其他可以嵌入到Electron中的选项,例如NeDB(邮袋(Loki.js),可能会更适合您的需求。

There are also several other options available that can embed with Electron like NeDB (Pouch, Loki.js) that might suit your needs better.

**更新**

您也许可以使用它: https://github.com/nosqlclient/nosqlclient-electron

可在网站上找到更多信息: https://www.nosqlclient。 com /

More info available on the website: https://www.nosqlclient.com/

看起来它是完全支持MongoDB的Electron的替代应用程序,使用Electron吗?

It looks like it's a replacement application for Electron entirely with MongoDB support, using Electron?

这篇关于将Mongodb嵌入Electron的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆