Load one collection's data into a database named after the key. Returns (db, n).
(key, source, drop=True, base_dir=None)
| 277 | # Public entry point |
| 278 | # --------------------------------------------------------------------------- # |
| 279 | def load_collection(key, source, drop=True, base_dir=None) -> tuple: |
| 280 | """Load one collection's data into a database named after the key. Returns (db, n).""" |
| 281 | cfg = collection_config(key) |
| 282 | transform = _transform_for(key) |
| 283 | docs = [ |
| 284 | _normalise(d, key, cfg, transform) |
| 285 | for d in _collect_docs(key, source, cfg, base_dir) |
| 286 | ] |
| 287 | db = key |
| 288 | if docs: |
| 289 | _ensure_db(db, drop=drop) |
| 290 | if cfg.get("design_doc"): |
| 291 | _install_design(db, cfg["design_doc"]) |
| 292 | _bulk_insert(db, docs) |
| 293 | _create_indexes(db, cfg.get("indexes")) |
| 294 | return db, len(docs) |
nothing calls this directly
no test coverage detected