From 443e757583b640a768912a69d9e3231db1ef362b Mon Sep 17 00:00:00 2001 From: Andros Fenollosa Date: Tue, 8 Nov 2022 23:29:57 +0100 Subject: [PATCH] Update README.md --- README.md | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 7eb3e7c..0fdabf4 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Only one: ```python fiable_db.add({"name": "Miguel", "age": 41, "height": 189}) -// {"id": 1, "rev": 1, "data": {"name": "Miguel", "age": 41, "height": 189}} +# {"id": 1, "rev": 1, "data": {"name": "Miguel", "age": 41, "height": 189}} ``` Various: @@ -61,11 +61,11 @@ fiable_db.add( {"name": "Valentina", "age": 12, "height": 142}, ] ) -// [ -// {"id": 2, "rev": 1, "data": {{"name": "Noelia", "age": 34, "height": 165}}, -// {"id": 3, "rev": 1, "data": {{"name": "Juan", "age": 41, "height": 187}}, -// {"id": 4, "rev": 1, "data": {{"name": "Valentina", "age": 83, "height": 172}}, -// ] +# [ +# {"id": 2, "rev": 1, "data": {{"name": "Noelia", "age": 34, "height": 165}}, +# {"id": 3, "rev": 1, "data": {{"name": "Juan", "age": 41, "height": 187}}, +# {"id": 4, "rev": 1, "data": {{"name": "Valentina", "age": 83, "height": 172}}, +# ] ``` ### Step 3: Update @@ -74,35 +74,35 @@ Update a key: ```python fiable_db.update(4, {"age": 21}) -// {"id": 4, "rev": 2, "data": {{"name": "Valentina", "age": 21, "height": 172}} +# {"id": 4, "rev": 2, "data": {{"name": "Valentina", "age": 21, "height": 172}} ``` Add new key: ```python fiable_db.update(4, {"is_active": True}) -// {"id": 4, "rev": 3, "data": {{"name": "Valentina", "age": 21, "height": 172, "is_active": True}} +# {"id": 4, "rev": 3, "data": {{"name": "Valentina", "age": 21, "height": 172, "is_active": True}} ``` Delete key: ```python fiable_db.update(4, {"height": None}) -// {"id": 4, "rev": 4, "data": {{"name": "Valentina", "age": 21, "is_active": True}} +# {"id": 4, "rev": 4, "data": {{"name": "Valentina", "age": 21, "is_active": True}} ``` Forcing new structure. ```python fiable_db.update(4, {"name": "Javier", "email": "foo@example.com"}, force=True) -// {"id": 4, "rev": 5, "data": {{"name": "Javier", "email": "foo@example.com"}} +# {"id": 4, "rev": 5, "data": {{"name": "Javier", "email": "foo@example.com"}} ``` ### Step 4: Delete ```python fiable_db.delete(4) -// {"id": 4, "rev": 6, "data": None} +# {"id": 4, "rev": 6, "data": None} ``` ### Step 5: Find one @@ -111,28 +111,28 @@ Search by id. ```python fiable_db.find_one(id=2) -// {"id": 2, "rev": 1, "data": {{"name": "Noelia", "age": 34, "height": 165}} +# {"id": 2, "rev": 1, "data": {{"name": "Noelia", "age": 34, "height": 165}} ``` Search by value. ```python fiable_db.find_one(data={"name": "Noelia"}) -// {"id": 2, "rev": 1, "data": {{"name": "Noelia", "age": 34, "height": 165}} +# {"id": 2, "rev": 1, "data": {{"name": "Noelia", "age": 34, "height": 165}} ``` Search by several values. ```python fiable_db.find_one(data={"name": "Noelia", "age": 34}) -// {"id": 2, "rev": 1, "data": {{"name": "Noelia", "age": 34, "height": 165}} +# {"id": 2, "rev": 1, "data": {{"name": "Noelia", "age": 34, "height": 165}} ``` No results. ```python fiable_db.find_one(data={"name": "Noelia", "is_active": False}) -// None +# None ``` ### Step 6: Find all @@ -140,10 +140,10 @@ fiable_db.find_one(data={"name": "Noelia", "is_active": False}) ```python fiable_db.find_all(data={"age": 41}) -// [ -// {"id": 1, "rev": 1, "data": {{"name": "Miguel", "age": 41, "height": 189}}, -// {"id": 3, "rev": 1, "data": {{"name": "Juan", "age": 41, "height": 187}}, -// ] +# [ +# {"id": 1, "rev": 1, "data": {{"name": "Miguel", "age": 41, "height": 189}}, +# {"id": 3, "rev": 1, "data": {{"name": "Juan", "age": 41, "height": 187}}, +# ] ``` ### Step 7: See previous revisions @@ -152,17 +152,17 @@ Previous version to be deleted. ```python fiable_db.find_one(id=4, rev=3) -// {"id": 4, "rev": 3, "data": {{"name": "Valentina", "age": 21, "height": 172, "is_active": True}} +# {"id": 4, "rev": 3, "data": {{"name": "Valentina", "age": 21, "height": 172, "is_active": True}} ``` You can also use negative numbers. ```python fiable_db.find_one(id=4, rev=-1) -// {"id": 4, "rev": 3, "data": {{"name": "Valentina", "age": 21, "height": 172, "is_active": True}} +# {"id": 4, "rev": 3, "data": {{"name": "Valentina", "age": 21, "height": 172, "is_active": True}} fiable_db.find_one(id=4, rev=-2) -// {"id": 4, "rev": 2, "data": {{"name": "Valentina", "age": 21, "height": 172}} +# {"id": 4, "rev": 2, "data": {{"name": "Valentina", "age": 21, "height": 172}} ``` ### Step 8: Working with tables or collections. @@ -171,13 +171,13 @@ You can create as many tables as you want. The default table is called `default` ```python fiable_db.add({"name": "Luciano", "age": 54, "height": 165}, table="users") -// {"id": 1, "rev": 1, "data": {"name": "Luciano", "age": 54, "height": 165}} +# {"id": 1, "rev": 1, "data": {"name": "Luciano", "age": 54, "height": 165}} fiable_db.find_one(id=1, table="users") // "users" table -// {"id": 1, "rev": 1, "data": {"name": "Luciano", "age": 54, "height": 165}} +# {"id": 1, "rev": 1, "data": {"name": "Luciano", "age": 54, "height": 165}} fiable_db.find_one(id=1) // Default table -// {"id": 1, "rev": 1, "data": {"name": "Miguel", "age": 41, "height": 189}} +# {"id": 1, "rev": 1, "data": {"name": "Miguel", "age": 41, "height": 189}} ``` ---