scruby 0.8.1__py3-none-any.whl → 0.9.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
scruby/db.py CHANGED
@@ -280,3 +280,11 @@ class Scruby[T]:
280
280
  results.append(doc)
281
281
  counter += 1
282
282
  return results or None
283
+
284
+ def collection_name(self) -> str:
285
+ """Get collection name."""
286
+ return self.__class_model.__name__
287
+
288
+ def collection_full_name(self) -> str:
289
+ """Get full name of collection."""
290
+ return f"{self.__db_root}/{self.__class_model.__name__}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scruby
3
- Version: 0.8.1
3
+ Version: 0.9.0
4
4
  Summary: A fast key-value storage library.
5
5
  Project-URL: Homepage, https://github.com/kebasyaty/scruby
6
6
  Project-URL: Repository, https://github.com/kebasyaty/scruby
@@ -288,6 +288,42 @@ if __name__ == "__main__":
288
288
  anyio.run(main)
289
289
  ```
290
290
 
291
+ ```python
292
+ """Get collection name."""
293
+
294
+ import anyio
295
+ import datetime
296
+ from typing import Annotated
297
+ from pydantic import BaseModel, EmailStr
298
+ from pydantic_extra_types.phone_numbers import PhoneNumber, PhoneNumberValidator
299
+ from scruby import Scruby, constants
300
+
301
+ constants.DB_ROOT = "ScrubyDB" # By default = "ScrubyDB"
302
+
303
+ class User(BaseModel):
304
+ """Model of User."""
305
+ first_name: str
306
+ last_name: str
307
+ birthday: datetime.datetime
308
+ email: EmailStr
309
+ phone: Annotated[PhoneNumber, PhoneNumberValidator(number_format="E164")]
310
+
311
+ async def main() -> None:
312
+ """Example."""
313
+ # Get collection of `User`.
314
+ user_coll = Scruby(User)
315
+
316
+ print(user_coll.collection_name()) # "User"
317
+ print(user_coll.collection_full_name()) # "ScrubyDB/User"
318
+
319
+ # Full database deletion.
320
+ # Hint: The main purpose is tests.
321
+ await Scruby.napalm()
322
+
323
+ if __name__ == "__main__":
324
+ anyio.run(main)
325
+ ```
326
+
291
327
  ## Changelog
292
328
 
293
329
  [View the change history](https://github.com/kebasyaty/scruby/blob/v0/CHANGELOG.md "Changelog").
@@ -0,0 +1,8 @@
1
+ scruby/__init__.py,sha256=myX7sG-7oAQZGdgfZtTGXYCCraTeuwi7SjBoltftpnM,648
2
+ scruby/constants.py,sha256=GbB-O0qaVdi5EHUp-zRAppFXLR-oHxpXUFVAOCpS0C8,1022
3
+ scruby/db.py,sha256=1tfDCwoKwUx0a6DfEOpPAV8NYuifmmrX8Q9gU3K6l58,10407
4
+ scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ scruby-0.9.0.dist-info/METADATA,sha256=7Durmb2_VtJ4plz-OM-vhzfLAM8QGYkmVTRX1KFfOYY,11533
6
+ scruby-0.9.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
+ scruby-0.9.0.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
8
+ scruby-0.9.0.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- scruby/__init__.py,sha256=myX7sG-7oAQZGdgfZtTGXYCCraTeuwi7SjBoltftpnM,648
2
- scruby/constants.py,sha256=GbB-O0qaVdi5EHUp-zRAppFXLR-oHxpXUFVAOCpS0C8,1022
3
- scruby/db.py,sha256=FWCrcpzP93V1fk7NXhp6x2UgGkwqvk7qXvphm38R0X8,10130
4
- scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- scruby-0.8.1.dist-info/METADATA,sha256=TpqA2Ukl-TnolmTr-mRTRIFGE2KcKdzm8tLP1xRWKFM,10632
6
- scruby-0.8.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
- scruby-0.8.1.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
8
- scruby-0.8.1.dist-info/RECORD,,
File without changes