Skip to content

Export a set of documents with given ids #18455

Answered by ayende
hshenMcc asked this question in Q&A
Discussion options

You must be logged in to vote

The easiest way to do that is to run a query:

from @all_docs where id() in ('employees/1-A', 'orders/1-A')

Then export as CSV and import as CSV

If you want to do that using import / export (which is important if you want to include attachments, time series, etc). You can filter during the export process (or the import one, for that matter).

Here is the relevant script:

const docIds = ["employees/1-A", "orders/1-A"];

if(docIds.indexOf(id(this)) == -1)
    throw 'skip';

Note that this still needs to scan through all the documents in the database. That is why if you just need to push the raw document data, you can do that more easily through CSV.

Replies: 4 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@hshenMcc
Comment options

@ayende
Comment options

@hshenMcc
Comment options

@ayende
Comment options

Answer selected by ayende
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@ayende
Comment options

Comment options

You must be logged in to vote
1 reply
@ayende
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants