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

Dump collection with query_params #71

Open
stephane-r opened this issue Jan 24, 2018 · 2 comments
Open

Dump collection with query_params #71

stephane-r opened this issue Jan 24, 2018 · 2 comments

Comments

@stephane-r
Copy link

Hi community :)

I would like dump my PouchDB collection with params.
I've test this, but no result : all my collection is dumped :

Presentations.dump(ws, { query_params: { state: 'static' }});

I want dump only object with state: 'static'. Exemple of my document :

{
  "name": "Item",
  "state: "static",
  "_id": "11c8a234-b4b1-4a67-b88a-c7afe267d369",
  "_rev": "1-6c3c3f61229d4744ab25f1cc55e0e347"
}

Anyone have idea ? :)

Thank you community !

@cepm-nate
Copy link

cepm-nate commented Jan 25, 2018

Yes, just did this recently.

In your .dump command, add a 'filter'. Something like this should work:

sourceDB.dump( dest_file, { filter : (doc,req) => {
	return doc.state === 'static';
}}).then(  r => {
	console.log('DB dump completed!');
}).catch( e => {
	console.log('Dump failed: ',e.message)
});

Note: if you are also going to turn on live syncing between this sourceDB and wherever this dump is headed, you should also consider creating a design doc with the same filter, and including it in your live sync command. :-)

@stephane-r
Copy link
Author

stephane-r commented Jan 26, 2018

Thank you, work nice ! Very good feature :)

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

2 participants