Code Monkey home page Code Monkey logo

Comments (9)

louischatriot avatar louischatriot commented on August 23, 2024

Hello,

This doesn't come as a surprise since nedb is not run in a separate process but instead in the same process as the node application. That means the persistence datafile can be written to by the two processes but an insert on the parent will not be reflected on the child's in-memory cache.

I don't think nedb should automatically be in a separate process though, since its goal is to be lightweight. That said, what we can do is a standalone application that uses nedb to provide a database accessible through HTTP.

I'm not sure I can to that in the near future since there are other priorities for nedb, but I don't think it would take too long so if you want to do it please tell me and when it's finished I'll link to it in nedb's readme.

from nedb.

louischatriot avatar louischatriot commented on August 23, 2024

PS: I was thinking about it again and in fact I don't think that building this cross-application version of nedb makes sense. If you need this, you probably want to use a large scale database such as MongoDB. The goal of nedb is to provide database functionality to small-scale, simple applications and that doesn't seem to be your case.

from nedb.

przemyslawpluta avatar przemyslawpluta commented on August 23, 2024

On the other hand you can setup db on the parent and just pass new entries from child via process.send(insert) and worker.on('message'). Not the prettiest way but still should do the trick.

from nedb.

louischatriot avatar louischatriot commented on August 23, 2024

You can certainly do it that way too but that's very custom so I wouldn't want to implement this in nedb. I'm not too sure how a simple application can need to share access to a common database with a child, are you sure mongodb is not the right solution for your needs ?

from nedb.

przemyslawpluta avatar przemyslawpluta commented on August 23, 2024

Application doesn't store a lot of entries in the db and while most of the heavy lifting is done on the forked child process data has to be accessed from the parent. With the nedb application can run in a smaller enviro without requirement for a large db setup.

from nedb.

louischatriot avatar louischatriot commented on August 23, 2024

I see. Since it's very specific, the best way to do it would be for you to manage cross process communication and have only one nedb running, in the child.

from nedb.

przemyslawpluta avatar przemyslawpluta commented on August 23, 2024

Just tested it and works pretty nice. By the way is nedb vulnerable to traditional SQL injection attacks?

from nedb.

louischatriot avatar louischatriot commented on August 23, 2024

No. The only thing that you could think of is putting arbitrary javascript code in a form. But since the serialization/deserialization doesn't use eval and new Function (only JSON), this code would never get executed.

from nedb.

przemyslawpluta avatar przemyslawpluta commented on August 23, 2024

Thanks Louis.

from nedb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.