2

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 command. 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.

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.com/en/guide/database-integration.html#sqlite 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? 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 Commented Jun 16, 2018 at 19:42
  • @UnholySheep If you turn your comment into an answer, I will accept it. It really helped, especially that link with the doc. Thank you! Commented Jun 19, 2018 at 18:01

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

0

I’ve been working with Vue.js and local databases for a while, and I recommend 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 complex 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.

1 Comment

I was a noob back then and @UnholySheep had the answer I needed and would still to this day recommend. Your approach is interesting too but the database will only store the data in YOUR browser, which isn't what I was looking for back then. Funny, to find such old questions after becoming a senior frontend engineer and having moved on from there since. :-) Thanks for answering this weird question!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.