scruby 0.8.0__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.
|
|
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
|
|
@@ -108,8 +108,9 @@ uv add scruby
|
|
|
108
108
|
|
|
109
109
|
import anyio
|
|
110
110
|
import datetime
|
|
111
|
+
from typing import Annotated
|
|
111
112
|
from pydantic import BaseModel, EmailStr
|
|
112
|
-
from pydantic_extra_types.phone_numbers import PhoneNumber
|
|
113
|
+
from pydantic_extra_types.phone_numbers import PhoneNumber, PhoneNumberValidator
|
|
113
114
|
from scruby import Scruby, constants
|
|
114
115
|
|
|
115
116
|
constants.DB_ROOT = "ScrubyDB" # By default = "ScrubyDB"
|
|
@@ -120,7 +121,7 @@ class User(BaseModel):
|
|
|
120
121
|
last_name: str
|
|
121
122
|
birthday: datetime.datetime
|
|
122
123
|
email: EmailStr
|
|
123
|
-
phone: PhoneNumber
|
|
124
|
+
phone: Annotated[PhoneNumber, PhoneNumberValidator(number_format="E164")]
|
|
124
125
|
|
|
125
126
|
async def main() -> None:
|
|
126
127
|
"""Example."""
|
|
@@ -165,8 +166,9 @@ Ideally, hundreds and even thousands of threads are required.
|
|
|
165
166
|
|
|
166
167
|
import anyio
|
|
167
168
|
import datetime
|
|
169
|
+
from typing import Annotated
|
|
168
170
|
from pydantic import BaseModel, EmailStr
|
|
169
|
-
from pydantic_extra_types.phone_numbers import PhoneNumber
|
|
171
|
+
from pydantic_extra_types.phone_numbers import PhoneNumber, PhoneNumberValidator
|
|
170
172
|
from scruby import Scruby, constants
|
|
171
173
|
from pprint import pprint as pp
|
|
172
174
|
|
|
@@ -180,7 +182,7 @@ class User(BaseModel):
|
|
|
180
182
|
last_name: str
|
|
181
183
|
birthday: datetime.datetime
|
|
182
184
|
email: EmailStr
|
|
183
|
-
phone: PhoneNumber
|
|
185
|
+
phone: Annotated[PhoneNumber, PhoneNumberValidator(number_format="E164")]
|
|
184
186
|
|
|
185
187
|
async def main() -> None:
|
|
186
188
|
"""Example."""
|
|
@@ -235,8 +237,9 @@ Ideally, hundreds and even thousands of threads are required.
|
|
|
235
237
|
|
|
236
238
|
import anyio
|
|
237
239
|
import datetime
|
|
240
|
+
from typing import Annotated
|
|
238
241
|
from pydantic import BaseModel, EmailStr
|
|
239
|
-
from pydantic_extra_types.phone_numbers import PhoneNumber
|
|
242
|
+
from pydantic_extra_types.phone_numbers import PhoneNumber, PhoneNumberValidator
|
|
240
243
|
from scruby import Scruby, constants
|
|
241
244
|
from pprint import pprint as pp
|
|
242
245
|
|
|
@@ -250,7 +253,7 @@ class User(BaseModel):
|
|
|
250
253
|
last_name: str
|
|
251
254
|
birthday: datetime.datetime
|
|
252
255
|
email: EmailStr
|
|
253
|
-
phone: PhoneNumber
|
|
256
|
+
phone: Annotated[PhoneNumber, PhoneNumberValidator(number_format="E164")]
|
|
254
257
|
|
|
255
258
|
async def main() -> None:
|
|
256
259
|
"""Example."""
|
|
@@ -285,6 +288,42 @@ if __name__ == "__main__":
|
|
|
285
288
|
anyio.run(main)
|
|
286
289
|
```
|
|
287
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
|
+
|
|
288
327
|
## Changelog
|
|
289
328
|
|
|
290
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,,
|
scruby-0.8.0.dist-info/RECORD
DELETED
|
@@ -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.0.dist-info/METADATA,sha256=Ktsxx4l5cmeVST2tzADKs7Hazi3WD1zjSS53QVpyJY8,10314
|
|
6
|
-
scruby-0.8.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
7
|
-
scruby-0.8.0.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
|
|
8
|
-
scruby-0.8.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|