Ask HN: Best Approach for MongoDB-Like Experience in Deno?

4 points by vfssantos 4 days ago

I've been building serverless applications with Deno and really appreciate its built-in KV store for simple data persistence. However, I'm finding myself missing MongoDB's query capabilities and document-oriented model.

For those using Deno in production:

1. How are you handling document-based data storage in Deno applications, especially for edge deployments?

2. Have you found any good abstractions over Deno KV that provide MongoDB-like querying (find with complex filters, update with operators like $set/$push, etc.)?

3. What's your approach to indexing and query optimization when using Deno KV for document storage?

4. If you migrated from a Node.js/MongoDB stack to Deno, what was your strategy for the database layer?

I'm considering building a thin MongoDB-compatible layer over Deno KV, but I'm wondering if there are existing solutions or if this approach has fundamental flaws I'm not seeing.

Any insights or experiences would be greatly appreciated!

billconan 4 days ago

I will just use sqlite to save json. it supports indexing and query

  • vfssantos 4 days ago

    Going straight to SQLite is a great option! The JSON1 extension is quite powerful (which are now part of sqlite core, right?). Are you using this with Deno currently?

    I'm curious about your approach to deployment, especially for edge functions. Do you bundle SQLite with your application, or are you using a hosted solution?

    Have you found any good abstractions or libraries that provide a document-oriented API over SQLite in Deno/Node? I'd be interested in how you handle things like nested document queries or array operations with the JSON1 extension in a friendlier manner.

    • billconan 3 days ago

      I attempted to develop my own embedded mongodb on top of sqlite in rust:

      https://github.com/shi-yan/hoardbase

      but then I realized that the sql syntax isn't too bad compared to mongodb, so I abandoned this idea.

      For my next project, I will still use sqlite. My app will be electron based, I will probably write rust based nodejs modules.

      • vfssantos 28 minutes ago

        Thanks for sharing your project! Hoardbase looks really interesting - I appreciate you taking the time to link it.

        Your experience of starting with the MongoDB API idea and then deciding SQL syntax was sufficient is really valuable feedback. It makes me wonder about the specific pain points that initially drove you toward a MongoDB API, and what aspects of SQL ended up working well enough for your needs.

        For document-oriented workloads, did you find any particular patterns or techniques with SQLite's JSON functions that made working with nested data and arrays more manageable? Or did you end up modeling your data differently to better fit SQL's approach?

        I'm also curious about your decision to use Rust for the implementation. Was that primarily for performance reasons, or were there other factors that led you in that direction?

        Thanks again for sharing your experience - it's really helpful to hear from someone who's explored this space before.