codepleb
codepleb

Reputation: 10571

How to embed a database into my vuejs app?

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.

Upvotes: 2

Views: 8429

Answers (2)

pubkey
pubkey

Reputation: 612

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.

Upvotes: 0

UnholySheep
UnholySheep

Reputation: 4096

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

Upvotes: 3

Related Questions