admin管理员组

文章数量:1429032

I know this is a "generic" question, but please read it before judging:

I try to create a vuejs fullstack application that i can build and run with a single mand. I use the vue-cli to create and build a project. Included is express and node (works fine). But I cannot figure out how to add database functionality to it. I thought mongodb and mongoose would fit, until I learned that I need a separate mongodb server running instead of getting it embedded within my build.

Is this even possible? I mean, android apps ship with SQLite that every app can use. Where do I need to research to get this job done? Google tells me to use mongoose, but it is not embedded as it seems.

I know this is a "generic" question, but please read it before judging:

I try to create a vuejs fullstack application that i can build and run with a single mand. I use the vue-cli to create and build a project. Included is express and node (works fine). But I cannot figure out how to add database functionality to it. I thought mongodb and mongoose would fit, until I learned that I need a separate mongodb server running instead of getting it embedded within my build.

Is this even possible? I mean, android apps ship with SQLite that every app can use. Where do I need to research to get this job done? Google tells me to use mongoose, but it is not embedded as it seems.

Share Improve this question asked Jun 16, 2018 at 16:30 codeplebcodepleb 10.6k15 gold badges76 silver badges119 bronze badges 4
  • 2 Vuejs is a front-end framework, you don't usually embed databases in there. And there's plenty of embedded databases, the most popular being SQLite, the ExpressJS website even has a simple example how to use it: expressjs./en/guide/database-integration.html#sqlite – UnholySheep Commented Jun 16, 2018 at 16:36
  • @UnholySheep If I can ship this with my app, I will definitely have a look at it! Thank you very much! EDIT: It looks like this is only an "in memory" database with no persistence layer? – codepleb Commented Jun 16, 2018 at 19:35
  • 2 SQLite can be used either purely in-memory or with persistence (in the form of database-files). You can read more about it on their official site and there's also some small explanations in e.g.: the sqlite3 docs – UnholySheep Commented Jun 16, 2018 at 19:42
  • @UnholySheep If you turn your ment into an answer, I will accept it. It really helped, especially that link with the doc. Thank you! – codepleb Commented Jun 19, 2018 at 18:01
Add a ment  | 

2 Answers 2

Reset to default 3

As requested, as an answer:

Databases are usually part of the back-end (in this case nodejs). There's plenty of choices for embedable databases, the most popular one is SQLite. It can be used either purely "in memory" or with persistence in the form of "database files". More information how to use it in node can be found in the node-sqlite3 documentation

I’ve been working with Vue.js and local databases for a while, and I remend giving RxDB in your vue app a try. It’s a great fit for Vue because it’s easy to integrate, supports reactivity out of the box, and lets you keep your data in sync between the browser and the server. One of RxDB’s standout features is its offline-first approach—it can store data locally and then sync seamlessly once the device is back online. Plus, it has plugins for encryption, conflict resolution, and server replication, which are all really helpful if you need to handle more plex use cases.

If RxDB isn’t your style or you want to explore alternatives, you could also look at PouchDB for a simpler offline-first approach, or Dexie.js if you prefer a more lightweight IndexedDB wrapper. Gun.js might be another interesting choice, especially if you’re building real-time collaborative applications.

本文标签: javascriptHow to embed a database into my vuejs appStack Overflow