Coder Social home page Coder Social logo

Comments (10)

akashnimare avatar akashnimare commented on July 19, 2024 1

@Belphemur Thanks a lot it worked 🎉 .

from node-json-db.

Belphemur avatar Belphemur commented on July 19, 2024

Hello @akashnimare

The problem surely lies here: https://github.com/zulip/zulip-electron/blob/fc5b7324d2dc48849e32dc3404116fde1ecfbcc0/app/main/index.js#L16

By default, JsonDB (well OS in general) will open a file relatively to the working directory. When you're developing it's not a problem at all. However, if the user launching the app doesn't have "write access" to the working directory (usually where the app is installed) the OS is not going to let your write hence the error you're seeing.

Also, I have stricly no idea how the library act in a "browser". You should give it a full path with __dirname since it has not been made to work natively in browser.

from node-json-db.

akashnimare avatar akashnimare commented on July 19, 2024

@Belphemur so is there any way I can make it work. node-json-db is awesome but if I am not able to use in electron then surely I'll have to use some other db 😞 .

from node-json-db.

Belphemur avatar Belphemur commented on July 19, 2024

I'd say, give a full path.

Using https://github.com/electron/electron/blob/master/docs/api/app.md#appgetpathname

And https://discuss.atom.io/t/open-external-file-with-electron/18569/7

You should be able to use the userData path for your database.

from node-json-db.

akashnimare avatar akashnimare commented on July 19, 2024

I can't make it work. I used this but no luck-

const data = db.getData(app.getPath('userData') + '/domain.json');
or
const data = db.getData(app.getAppPath() + '/domain.json');

from node-json-db.

Belphemur avatar Belphemur commented on July 19, 2024

Not when calling the getData. When initializing the database.

https://github.com/zulip/zulip-electron/blob/fc5b7324d2dc48849e32dc3404116fde1ecfbcc0/app/main/index.js#L16

const db = new JsonDB(app.getPath('userData') + '/domain', true, true);

Same at each place you are creating a JsonDB object.

from node-json-db.

akashnimare avatar akashnimare commented on July 19, 2024

@Belphemur hey, I'm getting this error again -

image

This happens when the db file is empty. Is there any way to handle this?

from node-json-db.

akashnimare avatar akashnimare commented on July 19, 2024

@Belphemur I don't know why but sometimes the db file gets corrupted which results in #21 (comment). Do you know the possible reason behind this?

from node-json-db.

Belphemur avatar Belphemur commented on July 19, 2024

from node-json-db.

akashnimare avatar akashnimare commented on July 19, 2024

I have only one instance of the db but I do reload the db file sometimes. Here is db file -
https://github.com/zulip/zulip-electron/blob/master/app/renderer/js/utils/domain-util.js
Let me know if you find anything suspicious which might cause this issue. I have no clues here 😭
(FYI only the domain.json file gets corrupted not others like setting.json, window-state.json)

from node-json-db.

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.