# pymongo_crud_use
## MongoDB Function Usage Guide
This guide explains the usage of each function provided in the MongoDB function module.
### 1. `initialize_collection(uri, db_name, collection_name)`
Initialize and return the MongoDB collection.
- **Parameters:**
- `uri`: MongoDB connection URI.
- `db_name`: Name of the MongoDB database.
- `collection_name`: Name of the MongoDB collection.
- **Returns:**
- MongoDB collection object.
### 2. `initialize_collection_with_certificate(uri, certificate_path, db_name, collection_name)`
Initialize and return the MongoDB collection using TLS certificate authentication.
- **Parameters:**
- `uri`: MongoDB connection URI.
- `certificate_path`: Path to the TLS certificate file.
- `db_name`: Name of the MongoDB database.
- `collection_name`: Name of the MongoDB collection.
- **Returns:**
- MongoDB collection object.
### 3. `set_data(collection, data)`
Insert data into the MongoDB collection.
- **Parameters:**
- `collection`: MongoDB collection object.
- `data`: Dictionary containing the data to be inserted.
- **Returns:**
- MongoDB insert result.
### 4. `get_data(collection)`
Retrieve data from the MongoDB collection where 'available' is True.
- **Parameters:**
- `collection`: MongoDB collection object.
- **Returns:**
- List of dictionaries representing retrieved data.
### 5. `get_all_data(collection)`
Retrieve all data from the MongoDB collection.
- **Parameters:**
- `collection`: MongoDB collection object.
- **Returns:**
- List of dictionaries representing all data in the collection.
### 6. `get_data_one(collection, id_data)`
Retrieve a single document from the MongoDB collection by its ID.
- **Parameters:**
- `collection`: MongoDB collection object.
- `id_data`: ID of the document to retrieve.
- **Returns:**
- Single document matching the provided ID or None.
### 7. `remove_data_bool(collection, id_data)`
Remove data from the MongoDB collection by its ID and set 'available' to False.
- **Parameters:**
- `collection`: MongoDB collection object.
- `id_data`: ID of the document to remove.
- **Returns:**
- MongoDB update result.
### 8. `remove_data(collection, id_data)`
Remove data from the MongoDB collection by its ID.
- **Parameters:**
- `collection`: MongoDB collection object.
- `id_data`: ID of the document to remove.
- **Returns:**
- MongoDB delete result.
### 9. `update_data(collection, id_data, data)`
Update data in the MongoDB collection by its ID.
- **Parameters:**
- `collection`: MongoDB collection object.
- `id_data`: ID of the document to update.
- `data`: Updated data as a dictionary.
- **Returns:**
- MongoDB update result.
### 10. `delete_db(collection)`
Delete all data from the MongoDB collection.
- **Parameters:**
- `collection`: MongoDB collection object.
- **Returns:**
- MongoDB delete result.
### 11. `count_db_bool(collection)`
Count documents in the MongoDB collection where 'available' is True.
- **Parameters:**
- `collection`: MongoDB collection object.
- **Returns:**
- Number of documents where 'available' is True.
### 12. `count_all_db(collection)`
Count all documents in the MongoDB collection.
- **Parameters:**
- `collection`: MongoDB collection object.
- **Returns:**
- Total number of documents in the collection.
### 13. `search_data_by_field(collection, field_name, field_value)`
Retrieve data from the MongoDB collection based on a specific field and its value.
- **Parameters:**
- `collection`: MongoDB collection object.
- `field_name`: Name of the field to search.
- `field_value`: Value to search for in the specified field.
- **Returns:**
- List of dictionaries representing retrieved data or None.
### 14. `upsert_data(collection, query, data)`
Update existing data if found, or insert new data if not found.
- **Parameters:**
- `collection`: MongoDB collection object.
- `query`: Query to identify the document to update.
- `data`: Data to be updated or inserted.
- **Returns:**
- MongoDB update result.
### 15. `search_across_fields(collection, search_query)`
Search across all fields of the MongoDB collection and return matching documents.
- **Parameters:**
- `collection`: MongoDB collection object.
- `search_query`: Search query string.
- **Returns:**
- List of dictionaries representing retrieved data or None.
### 16. `search_all_fields(collection, search_term)`
Search for the given term in all fields of the MongoDB collection.
- **Parameters:**
- `collection`: MongoDB collection object.
- `search_term`: Term to search for in all fields.
- **Returns:**
- List of dictionaries representing retrieved data or None.
### 17. `close_connection(collection)`
Close the connection to the MongoDB database.
- **Parameters:**
- `collection`: MongoDB collection object.
### 18. `uuid_id()`
Generate a UUID using the [uuid7](https://pypi.org/project/uuid7/) strategy.
- **Returns:**
- UUID string.
### 19. `test_connection(collection)`
MongoDB connection testing
- **Parameters:**
- `collection`: MongoDB collection object.
Raw data
{
"_id": null,
"home_page": "https://github.com/hecdelatorre/pymongo_crud_use.git",
"name": "pymongo-crud-use",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Your Name",
"author_email": "your.email@example.com",
"download_url": "https://files.pythonhosted.org/packages/15/6f/601f1035808e8a5811dbfacc7d22192b1c46ff7feffb94625d563bef9f3a/pymongo_crud_use-0.6.1.tar.gz",
"platform": null,
"description": "# pymongo_crud_use\n\n## MongoDB Function Usage Guide\n\nThis guide explains the usage of each function provided in the MongoDB function module.\n\n### 1. `initialize_collection(uri, db_name, collection_name)`\n\nInitialize and return the MongoDB collection.\n\n- **Parameters:**\n - `uri`: MongoDB connection URI.\n - `db_name`: Name of the MongoDB database.\n - `collection_name`: Name of the MongoDB collection.\n\n- **Returns:**\n - MongoDB collection object.\n\n### 2. `initialize_collection_with_certificate(uri, certificate_path, db_name, collection_name)`\n\nInitialize and return the MongoDB collection using TLS certificate authentication.\n\n- **Parameters:**\n - `uri`: MongoDB connection URI.\n - `certificate_path`: Path to the TLS certificate file.\n - `db_name`: Name of the MongoDB database.\n - `collection_name`: Name of the MongoDB collection.\n\n- **Returns:**\n - MongoDB collection object.\n\n### 3. `set_data(collection, data)`\n\nInsert data into the MongoDB collection.\n\n- **Parameters:**\n - `collection`: MongoDB collection object.\n - `data`: Dictionary containing the data to be inserted.\n\n- **Returns:**\n - MongoDB insert result.\n\n### 4. `get_data(collection)`\n\nRetrieve data from the MongoDB collection where 'available' is True.\n\n- **Parameters:**\n - `collection`: MongoDB collection object.\n\n- **Returns:**\n - List of dictionaries representing retrieved data.\n\n### 5. `get_all_data(collection)`\n\nRetrieve all data from the MongoDB collection.\n\n- **Parameters:**\n - `collection`: MongoDB collection object.\n\n- **Returns:**\n - List of dictionaries representing all data in the collection.\n\n### 6. `get_data_one(collection, id_data)`\n\nRetrieve a single document from the MongoDB collection by its ID.\n\n- **Parameters:**\n - `collection`: MongoDB collection object.\n - `id_data`: ID of the document to retrieve.\n\n- **Returns:**\n - Single document matching the provided ID or None.\n\n### 7. `remove_data_bool(collection, id_data)`\n\nRemove data from the MongoDB collection by its ID and set 'available' to False.\n\n- **Parameters:**\n - `collection`: MongoDB collection object.\n - `id_data`: ID of the document to remove.\n\n- **Returns:**\n - MongoDB update result.\n\n### 8. `remove_data(collection, id_data)`\n\nRemove data from the MongoDB collection by its ID.\n\n- **Parameters:**\n - `collection`: MongoDB collection object.\n - `id_data`: ID of the document to remove.\n\n- **Returns:**\n - MongoDB delete result.\n\n### 9. `update_data(collection, id_data, data)`\n\nUpdate data in the MongoDB collection by its ID.\n\n- **Parameters:**\n - `collection`: MongoDB collection object.\n - `id_data`: ID of the document to update.\n - `data`: Updated data as a dictionary.\n\n- **Returns:**\n - MongoDB update result.\n\n### 10. `delete_db(collection)`\n\nDelete all data from the MongoDB collection.\n\n- **Parameters:**\n - `collection`: MongoDB collection object.\n\n- **Returns:**\n - MongoDB delete result.\n\n### 11. `count_db_bool(collection)`\n\nCount documents in the MongoDB collection where 'available' is True.\n\n- **Parameters:**\n - `collection`: MongoDB collection object.\n\n- **Returns:**\n - Number of documents where 'available' is True.\n\n### 12. `count_all_db(collection)`\n\nCount all documents in the MongoDB collection.\n\n- **Parameters:**\n - `collection`: MongoDB collection object.\n\n- **Returns:**\n - Total number of documents in the collection.\n\n### 13. `search_data_by_field(collection, field_name, field_value)`\n\nRetrieve data from the MongoDB collection based on a specific field and its value.\n\n- **Parameters:**\n - `collection`: MongoDB collection object.\n - `field_name`: Name of the field to search.\n - `field_value`: Value to search for in the specified field.\n\n- **Returns:**\n - List of dictionaries representing retrieved data or None.\n\n### 14. `upsert_data(collection, query, data)`\n\nUpdate existing data if found, or insert new data if not found.\n\n- **Parameters:**\n - `collection`: MongoDB collection object.\n - `query`: Query to identify the document to update.\n - `data`: Data to be updated or inserted.\n\n- **Returns:**\n - MongoDB update result.\n\n### 15. `search_across_fields(collection, search_query)`\n\nSearch across all fields of the MongoDB collection and return matching documents.\n\n- **Parameters:**\n - `collection`: MongoDB collection object.\n - `search_query`: Search query string.\n\n- **Returns:**\n - List of dictionaries representing retrieved data or None.\n\n### 16. `search_all_fields(collection, search_term)`\n\nSearch for the given term in all fields of the MongoDB collection.\n\n- **Parameters:**\n - `collection`: MongoDB collection object.\n - `search_term`: Term to search for in all fields.\n\n- **Returns:**\n - List of dictionaries representing retrieved data or None.\n\n### 17. `close_connection(collection)`\n\nClose the connection to the MongoDB database.\n\n- **Parameters:**\n - `collection`: MongoDB collection object.\n\n### 18. `uuid_id()`\n\nGenerate a UUID using the [uuid7](https://pypi.org/project/uuid7/) strategy.\n\n- **Returns:**\n - UUID string.\n\n### 19. `test_connection(collection)`\n\nMongoDB connection testing\n\n- **Parameters:**\n - `collection`: MongoDB collection object.\n\n",
"bugtrack_url": null,
"license": "GPL-3.0",
"summary": "A package for MongoDB CRUD operations using PyMongo",
"version": "0.6.1",
"project_urls": {
"Homepage": "https://github.com/hecdelatorre/pymongo_crud_use.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9e79e19e77b4fd630a2140b09cdc66d65c71e69fce5d54a1c56507b08d8299a6",
"md5": "45e60b0df5c356af4d15e2bf4054c7cf",
"sha256": "ba6c837ead6c758fe435c8149204c0bc156bf03c161fc621a2ae9baf7f041b11"
},
"downloads": -1,
"filename": "pymongo_crud_use-0.6.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "45e60b0df5c356af4d15e2bf4054c7cf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 17305,
"upload_time": "2024-02-17T20:31:38",
"upload_time_iso_8601": "2024-02-17T20:31:38.985782Z",
"url": "https://files.pythonhosted.org/packages/9e/79/e19e77b4fd630a2140b09cdc66d65c71e69fce5d54a1c56507b08d8299a6/pymongo_crud_use-0.6.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "156f601f1035808e8a5811dbfacc7d22192b1c46ff7feffb94625d563bef9f3a",
"md5": "2118a02b357bd7d7e4ad2f5ebfcebc96",
"sha256": "fa2f036862ee77c6cb23a36ca5c8ade465235d58af66bfd43d44c5ebdd7f0dd7"
},
"downloads": -1,
"filename": "pymongo_crud_use-0.6.1.tar.gz",
"has_sig": false,
"md5_digest": "2118a02b357bd7d7e4ad2f5ebfcebc96",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 16725,
"upload_time": "2024-02-17T20:31:40",
"upload_time_iso_8601": "2024-02-17T20:31:40.664297Z",
"url": "https://files.pythonhosted.org/packages/15/6f/601f1035808e8a5811dbfacc7d22192b1c46ff7feffb94625d563bef9f3a/pymongo_crud_use-0.6.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-17 20:31:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hecdelatorre",
"github_project": "pymongo_crud_use",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pymongo-crud-use"
}