Skip to content

Commit 48908be

Browse files
authored
Merge pull request #183 from poissoncorp/RDBC-704
RDBC-704 Added bulk insert documentation section to the readme
2 parents 5631b2a + 204ba81 commit 48908be

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ Although new API isn't compatible with the previous one, it comes with **many im
150150
[Patching](#advanced-patching),
151151
[Subscriptions](#subscriptions),
152152
[Counters](#counters),
153+
[Bulk Insert](#bulk-insert),
153154
[Using classes](#using-classes-for-entities),
154155
[Working with secure server](#working-with-a-secure-server),
155156
[Building & running tests](#building)
@@ -1104,6 +1105,34 @@ results = self.store.operations.send(CounterBatchOperation(counter_batch))
11041105
> <small>[counters indexes](https:///github.com/ravendb/ravendb-python-client/blob/4ac192652bf57d304e1b48032d9acee56f2590b8/ravendb/tests/counters_tests/test_query_on_counters.py#L683)</small>
11051106
11061107
1108+
1109+
## Bulk insert
1110+
Bulk insert is the efficient way to store a large amount of documents.
1111+
1112+
https://ravendb.net/docs/article-page/5.4/csharp/client-api/bulk-insert/how-to-work-with-bulk-insert-operation.
1113+
1114+
For example:
1115+
1116+
```python
1117+
foo_bar1 = FooBar("John Doe")
1118+
foo_bar2 = FooBar("Jane Doe")
1119+
foo_bar3 = FooBar("John")
1120+
foo_bar4 = FooBar("Jane")
1121+
1122+
with store.bulk_insert() as bulk_insert:
1123+
bulk_insert.store(foo_bar1)
1124+
bulk_insert.store(foo_bar2)
1125+
bulk_insert.store_as(foo_bar3, "foobars/66")
1126+
bulk_insert.store_as(foo_bar4, "foobars/99", MetadataAsDictionary({"some_metadata_value": 75}))
1127+
```
1128+
The 3rd insert will store document named "foobars/66".
1129+
1130+
The 4th insert will store document with custom name and extra metadata.
1131+
1132+
>##### Related tests:
1133+
> <small>[simple bulk insert](https:///github.com/ravendb/ravendb-python-client/blob/45cb934e8ecc45d935afe3dd1dc96b40f94bcb00/ravendb/tests/jvm_migrated_tests/client_tests/test_bulk_inserts.py#L18-L44)</small>
1134+
> <small>[modifying metadata on bulk insert](https:///github.com/ravendb/ravendb-python-client/blob/45cb934e8ecc45d935afe3dd1dc96b40f94bcb00/ravendb/tests/jvm_migrated_tests/client_tests/test_bulk_inserts.py#L56-L68)</small>
1135+
11071136
## Using classes for entities
11081137
11091138
1. Define your model as class.

0 commit comments

Comments
 (0)