|
| 1 | +Metadata-Version: 2.1 |
| 2 | +Name: quickmongo.py |
| 3 | +Version: 1.0.0 |
| 4 | +Summary: A simple and quick wrapper for pymongo! |
| 5 | +Home-page: https://github.com/Scientific-Guy/quickmongo.py |
| 6 | +License: MIT |
| 7 | +Description: <div align="center"> |
| 8 | + <img src="https://github.com/Scientific-Guy/decimaldev/blob/master/assets/Quickmongo.png?raw=true"> |
| 9 | + <div> |
| 10 | + <a href="https://pypi.org/project/quickmongo.py/"><img src="https://img.shields.io/pypi/l/quickmongo.py?label=License&style=for-the-badge"></a> |
| 11 | + <a href="https://pypi.org/project/quickmongo.py/"><img src="https://img.shields.io/pypi/v/quickmongo.py?label=Version&style=for-the-badge"></a> |
| 12 | + <a href="https://pypi.org/project/quickmongo.py/"><img src="https://img.shields.io/pypi/format/quickmongo.py?label=Format&style=for-the-badge"></a> |
| 13 | + <a href="https://github.com/Scientific-Guy/quickmongo.py/"><img src="https://img.shields.io/github/repo-size/scientific-guy/quickmongo.py?label=Size&style=for-the-badge"></a> |
| 14 | + <a href="https://discord.gg/FrduEZd"><img src="https://img.shields.io/discord/736099894963601438?label=Discord&style=for-the-badge"></a> |
| 15 | + </div><br> |
| 16 | + </div> |
| 17 | + |
| 18 | + # Quick Intro |
| 19 | + Quickmongo.py is a quick wrapper for pymongo to access mongodb! You can use pymongo if you know it! |
| 20 | + |
| 21 | + # Quick Docs |
| 22 | + |
| 23 | + ## Installation |
| 24 | + |
| 25 | + **In your terminal:** |
| 26 | + ``` |
| 27 | + pip install quickmongo.py |
| 28 | + ``` |
| 29 | + |
| 30 | + **In your python file:** |
| 31 | + ```py |
| 32 | + from quickmongo import Database |
| 33 | + |
| 34 | + # If you are using locally |
| 35 | + db = Database('mongodb://localhost:27017/', {'db_name': 'local'}) |
| 36 | + |
| 37 | + # if you are using 'mongodb+srv://' uri then you should do something like this |
| 38 | + db = Database(mongoURL) |
| 39 | + # mongourl will be the 'mongodb+srv://' uri link |
| 40 | + # clusterName will be the name of the mongoose cluster. Eg:- Cluster0 |
| 41 | + # Incase if you don't know what is your clustername you will get an TypeError with available clusters! |
| 42 | + ``` |
| 43 | + |
| 44 | + ## Options of Databases |
| 45 | + |
| 46 | + Set some options for your database as a dict which is optional |
| 47 | + |
| 48 | + ```py |
| 49 | + options = { |
| 50 | + 'collection_name': 'yourCollectionName', # Collection name will be 'python' as default |
| 51 | + 'db_name': 'Cluster0' # This is optional unless you are using localhost you have to set it to local! |
| 52 | + } |
| 53 | + |
| 54 | + db = Database(mongoURL, options) |
| 55 | + # mongoURL is described above |
| 56 | + ``` |
| 57 | + |
| 58 | + ## Get databases and collections |
| 59 | + |
| 60 | + ```py |
| 61 | + # Get all database names under the link |
| 62 | + print(db.all_database_names()) |
| 63 | + # Check if the given database exists in the list |
| 64 | + print(db.database_exists('Cluster0')) |
| 65 | + |
| 66 | + # Get all collections names under the link |
| 67 | + print(db.all_collection_names()) |
| 68 | + # Check if the given collection exists in the list |
| 69 | + print(db.collection_exists('python')) |
| 70 | + ``` |
| 71 | + |
| 72 | + ## All Operations |
| 73 | + |
| 74 | + ```py |
| 75 | + db.set('foo', 'bar') # Will set value 'bar' for the key 'foo' |
| 76 | + db.get('foo') # Will return 'bar' which is the value of the key 'foo' |
| 77 | + |
| 78 | + db.all() # Will return all keys and values of the collection! {'key': 'foo', 'value': 'bar'} as a dict |
| 79 | + db.startswith('f') # Will sort all data whose keys startswith 'f' as {'key': 'foo', 'value': 'bar'} |
| 80 | + |
| 81 | + db.delete('foo') # Will delete value of the key 'foo' |
| 82 | + db.delete_all() # Will delete all values of the all keys! Simple drop() function |
| 83 | + |
| 84 | + db.set('foo', 1) # Simple set function given description above |
| 85 | + |
| 86 | + db.add('foo', 2) # Will add 2 to the old value. So the current value will be 3 |
| 87 | + db.subtract('foo', 1) # Will subtract 1 from old value of the key 'foo'. So the current value will be 1 |
| 88 | + |
| 89 | + db.math('foo', '*', 5) # Will multiply value by 5 so 1*5 = 5 |
| 90 | + db.math('foo', '**', 5) # 5**5 = 25 |
| 91 | + db.math('foo', '/', 5) # 25/5 = 5 |
| 92 | + db.math('foo', '+', 1) # 5+1 = 6 |
| 93 | + db.math('foo', '-', 1) # 6-1 = 5 |
| 94 | + |
| 95 | + db.typeof('foo') # Its currently int so it will return <class 'int'> |
| 96 | + ``` |
| 97 | + |
| 98 | + ## Events |
| 99 | + |
| 100 | + Events are functions which will trigger on paticular times |
| 101 | + |
| 102 | + **Ready Event:** |
| 103 | + ```py |
| 104 | + def ready(): |
| 105 | + print('Connected with database') |
| 106 | + |
| 107 | + db = Database( |
| 108 | + mongoURL='your-url', |
| 109 | + events={ |
| 110 | + 'ready': ready |
| 111 | + } |
| 112 | + ) |
| 113 | + |
| 114 | + # Will run ready callback when db is ready! |
| 115 | + ``` |
| 116 | + |
| 117 | + > Contribute codes to this packages by github [here](https://github.com/Scientific-Guy/quickmongo.py) |
| 118 | + |
| 119 | + # Support |
| 120 | + |
| 121 | + - [Join our Discord Server](https://discord.gg/FrduEZd) |
| 122 | + - [GitHub Repo](https://github.com/Scientific-Guy/quickmongo.py) |
| 123 | + |
| 124 | +Keywords: quickmongo.py |
| 125 | +Platform: UNKNOWN |
| 126 | +Classifier: License :: OSI Approved :: MIT License |
| 127 | +Classifier: Programming Language :: Python :: 3 |
| 128 | +Classifier: Programming Language :: Python :: 3.7 |
| 129 | +Description-Content-Type: text/markdown |
0 commit comments