-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add create_indexes_for_multiple_databases * Add drop_indexes_for_multiple_databases * Release 0.9.0
- Loading branch information
Showing
58 changed files
with
1,678 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,31 @@ | ||
.vscode/ | ||
# folders | ||
*.egg-info/ | ||
.hypothesis/ | ||
.idea/ | ||
*.pyc | ||
test.db | ||
.coverage | ||
.pytest_cache/ | ||
.mypy_cache/ | ||
.pytest_cache/ | ||
.scannerwork/ | ||
.tox/ | ||
.venv/ | ||
.vscode/ | ||
__pycache__/ | ||
*.egg-info/ | ||
htmlcov/ | ||
venv/ | ||
.idea/ | ||
virtualenv/ | ||
build/ | ||
dist/ | ||
node_modules/ | ||
results/ | ||
site/ | ||
site_lang/ | ||
target/ | ||
|
||
# files | ||
**/*.so | ||
**/*.sqlite | ||
*.iml | ||
**/*_test* | ||
.DS_Store | ||
.coverage | ||
.coverage.* | ||
.python-version | ||
coverage.* | ||
example.sqlite |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Registry | ||
|
||
When using the **Mongoz**, you must use the **Registry** object to tell exactly where the | ||
database is going to be. | ||
|
||
Imagine the registry as a mapping between your documents and the database where is going to be written. | ||
|
||
And is just that, nothing else and very simple but effective object. | ||
|
||
The registry is also the object that you might want to use when generating migrations using | ||
Alembic. | ||
|
||
```python hl_lines="19" | ||
{!> ../../../docs_src/registry/model.py !} | ||
``` | ||
|
||
## Parameters | ||
|
||
* **url** - The database URL to connect to. | ||
|
||
```python | ||
from mongoz import Registry | ||
|
||
registry = Registry(url="mongodb://localhost:27017") | ||
``` | ||
|
||
## Custom registry | ||
|
||
Can you have your own custom Registry? Yes, of course! You simply need to subclass the `Registry` | ||
class and continue from there like any other python class. | ||
|
||
```python | ||
{!> ../../../docs_src/registry/custom_registry.py !} | ||
``` | ||
|
||
## Run some document checks | ||
|
||
Sometimes you might want to make sure that all the documents have the indexes up to date beforehand. This | ||
can be particularly useful if you already have a document and some indexes or were updated, added or removed. This | ||
functionality runs those checks for all the documents of the given registry. | ||
|
||
```python | ||
{!> ../../../docs_src/registry/document_checks.py !} | ||
``` | ||
|
||
### Using within a framework | ||
|
||
This functionality can be useful to be also plugged if you use, for example, an ASGI Framework such as Starlette, | ||
[Lilya](https://lilya.dev) or [Esmerald](https://esmerald.dev). | ||
|
||
These frameworks handle the event lifecycle for you and this is where you want to make sure these checks are run beforehand. | ||
|
||
Since Mongoz is from the same team as [Lilya](https://lilya.dev) and [Esmerald](https://esmerald.dev), let us see how it | ||
would look like with Esmerald. | ||
|
||
```python | ||
{!> ../../../docs_src/registry/asgi_fw.py !} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.