# Jdbase-client Docs

### Jdbase-client Documentation <a href="#jdbase-client-documentation" id="jdbase-client-documentation"></a>

### Overview <a href="#overview" id="overview"></a>

`jdbase-client` is a Python library designed to provide a convenient interface for interacting with [JDBase](https://github.com/rakibmia7254/JDBase) remote database via an HTTP API. It simplifies common database operations such as creating, reading, updating, and deleting records, as well as performing custom queries. This library assumes that a compatible server is running and accessible at the provided API endpoint.

### Installation <a href="#installation" id="installation"></a>

You can install `jdbase-client` via pip:

```bash
pip install jdbase-client
```

### Usage <a href="#usage" id="usage"></a>

To use `jdbase-client`, you need to instantiate a `Database` object with the necessary configuration. This configuration includes the API key, API endpoint, and the name of the database. Once instantiated, you can use this object to perform various database operations.

#### Example <a href="#example" id="example"></a>

```python
from jdbase_client import Database

# Configuration settings
config = {
    'api_key': 'adminkey',
    'api_endpoint': 'http://127.0.0.1:5000/api',
    'db': 'db2'
}

# Instantiate the Database object
db = Database(config)

# Example usage: Matching records
matching_records = db.match({"id": 2, "age": 30})
print(matching_records)
```

### Class: `Database` <a href="#class-database" id="class-database"></a>

#### Methods <a href="#methods" id="methods"></a>

**`create(query: dict) -> dict`**

Creates a new record in the database.

* `query`: A dictionary representing the data to be inserted.

*Example:*

```python
db.create({
    "name":"Rakib Hossain",
    "age":22,"skill":"python"
    })
```

Returns:\
A dictionary containing the result of the operation.

**`get_by(query: dict) -> dict`**

Retrieves records from the database based on the provided query.

* `query`: A dictionary representing the query parameters. *Example:*

  db.get\_by({"id: 5})

Returns:\
A dictionary containing the retrieved records.

**`update(query: dict, update_query: dict) -> dict`**

Updates records in the database based on the provided query and update query.

* `query`: A dictionary representing the query to identify records to be updated.
* `update_query`: A dictionary representing the update operation to be performed on matching records.

*Example:*

```python
db.update({
    "Skill": "Python"
},
{
    "Skill":"Python_Api"
})
```

Returns:\
A dictionary containing the result of the operation.

**`delete(query: dict) -> dict`**

Deletes records from the database based on the provided query.

* `query`: A dictionary representing the query to identify records to be deleted.

*Example:*

```python
db.delete({"skill":"PHP"})
```

Returns:\
A dictionary containing the result of the operation.

**`match(query: dict) -> dict`**

Performs a custom matching query on the database.

* `query`: A dictionary representing the matching criteria.

*Example:*

```python
db.match({"email":"user@jdmail.com",
    "password":"user@password"})
```

Returns:\
A dictionary containing the matching records.

**`create_db(query: dict) -> dict`**

Creating New Database.

* `query`: A dictionary representing Name of Database

*Example:*

```python
db.create_db({"name":"users"})
```

Returns:\
A dictionary containing the matching records.

### Conclusion <a href="#conclusion" id="conclusion"></a>

`jdbase-client` simplifies database interactions by providing an easy-to-use interface for common operations. By following the provided documentation, you can seamlessly integrate this library into your Python projects and interact with your [JDBase](https://github.com/rakibmia7254/JDBase) remote database.

Checkout [JDBase Here](https://github.com/rakibmia7254/JDBase)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rakibmia7254.gitbook.io/jdbase/jdbase-client-docs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
