GithubHelp home page GithubHelp logo

utopia-php / database Goto Github PK

View Code? Open in Web Editor NEW
60.0 9.0 48.0 5.86 MB

Lite & fast micro PHP database abstraction library that is **easy to use**.

License: MIT License

Dockerfile 0.21% PHP 99.77% Shell 0.02%
utopia-framework hacktoberfest

database's People

Contributors

2002bishwajeet avatar abnegate avatar algyjr avatar apoorvdwi avatar brandonroberts avatar christyjacob4 avatar eldadfux avatar everly-gif avatar faisalill avatar fanatic75 avatar fogelito avatar gepd avatar kodumbeats avatar ln11211 avatar lohanidamodar avatar loks0n avatar meldiron avatar shimonewman avatar sin-sumit avatar stnguyen90 avatar torstendittmann avatar vermakhushboo avatar wess avatar yashsomalkar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

database's Issues

๐Ÿš€ Feature: updateDocumentBy

๐Ÿ”– Feature description

$resp = $DB::updateDocumentBy('db', 'collection', [
    Query.select(['foo', 'bar'])
], {
    'bar': 'bla',
    'splash': 'hash'
});

๐ŸŽค Pitch

Alternate way for SELECT statement when Document ID isn't available. Might be slower in terms of a INNER JOIN not looking for _uid as a PRIMARY KEY.

Allows for more natural thinking in programming, and for example, updateDocumentBy APIKey or any other UNIQUE Column, in our case, in a MariaDB Table.

I thought something like this

Screenshot 2023-12-05 at 13 46 58

Thoughts?

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: MariaDB - Count methods using OR condition in query

๐Ÿ‘Ÿ Reproduction steps

$db->count(
    Audit::COLLECTION, 
    [
        new Query('column1', Query::EQUALS, ['test'],
        new Query('column2', Query::EQUALS, ['a', 'b']
    ]
);

Will produce following conditions in the SQL query:

  AND table_main.column1 = 'test'
  AND table_main.column2 = 'a'
  OR table_main.column2 = 'b'

๐Ÿ‘ Expected behavior

AND table_main.column1 = 'test'
AND 
    (
        table_main.column2 = 'a'
        OR table_main.column2 = 'b'
    )

๐Ÿ‘Ž Actual Behavior

see above.

Example from the complete query:

SELECT COUNT(1) as sum 
FROM (
    SELECT 1 
    FROM project_console_internal.audit table_main
    WHERE 1=1 
    AND 1=1 
    AND table_main.resource = :attribute_0_0_resource 
    AND table_main.event = :attribute_1_0_event 
    OR table_main.event = :a
) table_count

๐ŸŽฒ Utopia Database version

Version 0.10.x

๐Ÿ˜ PHP Version

PHP 8.0.x

๐Ÿ’ป Operating system

MacOS

๐Ÿงฑ Your Environment

No response

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

Update `Utopia\Database\Database->count()` to ignore non-filter queries

In several places in Appwrite, we have to do:

        $filterQueries = Query::groupByType($queries)['filters'];

        $response->dynamic(new Document([
            'users' => $dbForProject->find('users', $queries),
            'total' => $dbForProject->count('users', $filterQueries, APP_LIMIT_COUNT),
        ]), Response::MODEL_USER_LIST);

It would be much cleaner to have Utopia\Database\Database->count() grab only the filters so that the code can be simplified to:

-        $filterQueries = Query::groupByType($queries)['filters'];

        $response->dynamic(new Document([
            'users' => $dbForProject->find('users', $queries),
-            'total' => $dbForProject->count('users', $filterQueries, APP_LIMIT_COUNT),
+            'total' => $dbForProject->count('users', $queries, APP_LIMIT_COUNT),
        ]), Response::MODEL_USER_LIST);

๐Ÿš€ Feature: Add AWS DynamoDB Adapter

๐Ÿ”– Feature description

Adapter to support using AWS DynamoDB database.

๐ŸŽค Pitch

  • DynamoDB is one of the most common highly performant NoSQL database services.

  • Backed by the resiliency of AWS, many teams choose to have DynamoDB as their production database.

  • Supporting DynamoDB will ensure that our users can use the service seamlessly from within the utopia framework.

  • This feature is inline with the maintainer AppWrite's vision to add support for DynamoDB database

  • I will be following guide to Add New Database Adapter

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

`Utopia\Database\Adapter::getIntLimit()` is not enforced

Each adapter must implement the getIntLimit() method, but it isn't enforced due to how we interpret $size for integer attributes.

In the case of strings, $size is pretty obvious - the length of the string. However, for integers (and before BIGINT), we just set $size = 0, so this check in createAttribute() would never actually prevent PDO from throwing the database exception:

case self::VAR_INTEGER:
$limit = ($signed) ? $this->adapter->getIntLimit() / 2 : $this->adapter->getIntLimit();
if($size > $limit) {
throw new Exception('Max size allowed for int is: '.number_format($limit));
}

Options to enforce int limit:

  • Check values for getIntLimit() as a filter when creating/updating documents
  • Get PDO error codes when size is exceeded and throw a custom Utopia\Database exception

๐Ÿš€ Feature: Contains for SQL(MariaDB/MySQL/SQLite) adapter

๐Ÿ”– Feature description

The SQL adapter including Maria/MySQL/SQLite should support the Contains query. I.E. attribute LIKE '%something%'

๐ŸŽค Pitch

Forgive me if I missed it somewhere, but I don't see any reason that the SQL connector doesn't already support "Contains" queries. The syntax is well know, supported by all 3 supported SQL engines(and most others), and simple and consistent across all versions of SQL.

So far as I can tell, this would only require changing 1 line of code to provide support, and one or two others to enable that support(instead of rejecting it).

src/Database/Adapter/SQL.php -> bindConditionValue, add:

Query::TYPE_CONTAINS => '%' . $this->escapeWildcards($value) . '%',

Please let me know if there is a reason this isn't already done. It seems so obvious that I can't help but think there is a reason it's not already done, and that I'm the one missing something obvious.

If needed, I'd be happy to clone, modify, and submit a PR.

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿš€ Feature: Adding Random option to query

๐Ÿ”– Feature description

Adding the option to select n items as random.

The implementation would look something like this

$documents = static::getDatabase()->find('movies', [
    Query::random(),
    Query::limit(5),
]);

Or with limit as the random parameter.

$documents = static::getDatabase()->find('movies', [
    Query::random(5),
]);

Adapter are required for:

  • MariaDB
  • MySQL
  • SQLite
  • Postgres
  • MongoDB.

๐ŸŽค Pitch

I first intend to add it as a feature for Appwrite database endpoints.
Also, It can be helpful in games, for example.

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿš€ Feature: CouchDB Adapter

๐Ÿ”– Feature description

An adapter for Apache CouchDB

๐ŸŽค Pitch

The point of this repository is to provide a "PHP database abstraction library". So, I intend to provide support for CouchDB. You're welcome.

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: Swoole client error when setting up locally

๐Ÿ‘Ÿ Reproduction steps

When I am installing the module for local development, I am getting the issue swoole coroutine client not found despite the the fact it has been installed and present in the vendor
Tried with Utopia-php/swoole as well
Any steps I am missing or is it a bug in the code?

๐Ÿ‘ Expected behavior

No error

๐Ÿ‘Ž Actual Behavior

Getting error

๐ŸŽฒ Utopia Database version

Version 0.10.x

๐Ÿ˜ PHP Version

PHP 8.0.x

๐Ÿ’ป Operating system

Linux

๐Ÿงฑ Your Environment

No response

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿš€ Feature: Refactor Queries

๐Ÿ”– Feature description

The last Query Refactor had some changes that could be improved, but we rushed forward due to lack of time.

๐ŸŽค Pitch

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿš€ Feature: Allow value for createdAt & updatedAt on create/update Document

๐Ÿ”– Feature description

This fields auto generate on insert / update

It can be usefull to force them via data like

{
...otherFields,
"$createdAt": "string or timestamp"
}

๐ŸŽค Pitch

In case of migration for others platform, without this we need to inject data directly on MariaDB, or we'll loose this information or if we simply need to change it for any other reason

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

Upgrade our issue templates to use GitHub issue forms โœ๏ธ

Introduction

GitHub has recently rolled out a public beta for their issue forms feature. This would allow you to create interactive issue templates and validate them ๐Ÿคฏ.

Appwrite currently uses the older issue template format. Your task is to create GitHub issue forms for this repository. Please use Appwrite's issue templates as a reference for this PR.

Tasks summary:

  • Fork & clone this repository
  • Prepare bug report issue form in .github/ISSUE_TEMPLATE/bug.yaml
  • Prepare documentation issue form in .github/ISSUE_TEMPLATE/documentation.yaml
  • Prepare feature request issue form in .github/ISSUE_TEMPLATE/feature.yaml
  • Push changes to master and test issue forms on your fork
  • Submit pull request

If you need any help, reach out to us on our Discord server.

Are you ready to work on this issue? ๐Ÿค” Let us know, and we will assign it to you ๐Ÿ˜Š

Happy Appwriting!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.