Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find() not returning all results #113

Closed
wjessup opened this issue Sep 18, 2017 · 1 comment
Closed

find() not returning all results #113

wjessup opened this issue Sep 18, 2017 · 1 comment

Comments

@wjessup
Copy link

wjessup commented Sep 18, 2017

I'm writing an electron app and have various db functions in a module that is loaded in main process and in the render process.

When the app loads in main I can do something like Project.find(...) and get 7 results ( correctly ).
I do the same in the render to load a list for display, call the same function from the same module, get 7 results (correctly).

Then I execute an action to save a new Project in main process.

After that I do the same .find() and get 8 results (correctly). In the callback where I log 8 results, I launch an event to do the .find() in the render.

It executes and I get 7 results (incorrect!).

Code in main process:

Project.find({ user: user._id }).then(projects => {
console.log(projects.length) // => 8 results
global.mainWindow.webContents.send('projects:changed') //triggeres render event as below
})

in render process:

ipcRenderer.on('projects:changed', (e,arg) => {
Project.find({ user: user._id }).then(projects => {
console.log(projects) // => 7 results.
self.setState({ projects })
})
})

Keep in mind this works as expected on app launch.

I'm stumped.

@wjessup
Copy link
Author

wjessup commented Sep 18, 2017

nm, read that this is related to each instance not looking at the JSON files but holding its own data in memory.

@wjessup wjessup closed this as completed Sep 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant