diff --git a/README.md b/README.md index 3f10ffc..45dd6d2 100644 --- a/README.md +++ b/README.md @@ -386,9 +386,11 @@ possible, they support Python dictionaries, dataclasses, and classes. ### .insert() -Creates a record. +Creates a record. In the name of flexibility, we test that dictionaries, +dataclasses, and classes all work. Returns an instance of the updated +record. -Insert a dictionary. +Insert using a dictionary. ``` python cats.insert({'name': 'Rex', 'weight': 12.2}) @@ -396,7 +398,7 @@ cats.insert({'name': 'Rex', 'weight': 12.2}) Cat(id=1, name='Rex', weight=12.2, uid=UNSET) -Insert a dataclass. +Insert using a dataclass. ``` python CatDC = cats.dataclass() @@ -405,7 +407,7 @@ cats.insert(CatDC(name='Tom', weight=10.2)) Cat(id=2, name='Tom', weight=10.2) -Insert a standard Python class +Insert using a standard Python class ``` python cat = cats.insert(Cat(name='Jerry', weight=5.2)) @@ -413,9 +415,10 @@ cat = cats.insert(Cat(name='Jerry', weight=5.2)) ### .update() -Updates a record. +Updates a record using a Python dict, dataclasses, and classes all work +and returns an instance of the updated record. -Update a dictionary: +Updating from a Python dict: ``` python cats.update(dict(id=cat.id, name='Jerry', weight=6.2)) @@ -423,6 +426,53 @@ cats.update(dict(id=cat.id, name='Jerry', weight=6.2)) Cat(id=3, name='Jerry', weight=6.2) +Updating from a dataclass: + +``` python +cats.update(CatDC(id=cat.id, name='Jerry', weight=6.3)) +``` + + Cat(id=3, name='Jerry', weight=6.3) + +Updating using a class: + +``` python +cats.update(Cat(id=cat.id, name='Jerry', weight=5.7)) +``` + + Cat(id=3, name='Jerry', weight=5.7) + +### .delete() + +Removing data is done by providing the primary key value of the record. + +``` python +# Farewell Jerry! +cats.delete(cat.id) +``` + +