arafatkn / laravel-datastore
A package for using google datastore as a database driver.
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
Requires
- php: ^7.3|^8.0
- ext-json: *
- google/cloud-datastore: ^1.12
- illuminate/database: ^6|^7|^8
- illuminate/http: ^6|^7|^8
- illuminate/pagination: ^6|^7|^8
- illuminate/support: ^6|^7|^8
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2022-06-29 09:05:03 UTC
README
A package for using google datastore as a database driver.
By using this package, you can use query builder
and eloquent
to access data from datastore.
Installation
You can install the package via composer:
composer require arafatkn/laravel-datastore
If you are using Laravel Package Auto-Discovery, you don't need you to manually add the ServiceProvider.
Without auto-discovery:
If you don't use auto-discovery, add the below ServiceProvider to the $providers
array in config/app.php
file.
Arafatkn\LaravelDatastore\DatastoreServiceProvider::class,
Roadmap
- Data read using query builder (available).
- Data read using eloquent model (available).
- Data insert (via query builder, using model soon).
- Data update (soon).
- Data delete (available).
- Cursor Paginate (soon).
- Relations (soon).
Usage
You need to add datastore
connection in config/database.php
file.
'connections' => [ ... 'datastore' => [ 'driver' => 'datastore', 'key_file_path' => env('GOOGLE_APPLICATION_CREDENTIALS', 'gcloud-credentials.json'), 'prefix' => env('DATASTORE_PREFIX', null), ], ... ],
Access using Eloquent Model
You need to extend Arafatkn\LaravelDatastore\Eloquent\Model
class instead of laravel's default eloquent model class.
Example-
<?php namespace App\Models; use Arafatkn\LaravelDatastore\Eloquent\Model; class Project extends Model { // Your works here }
Access using Query Builder
Example-
DB::connection('datastore') ->table('projects') ->where('project_id', '>', 5) ->skip(3) ->take(5) ->get();
It will return a collection.
Tested Builder Functions
- connection
- table
- from
- select (for projection query)
- kind (same as table)
- where (Available: = , > , < , >= , <= )
- limit
- take
- skip
- get
- simplePaginate
- paginate (works same as simplePaginate)
- first
- delete
- insert
- upsert
- find / lookup
Contribution Guide
This driver is still not stable. You can contribute by reporting bugs, fixing bugs, reviewing pull requests and more ways. Go to issues section, and you can start working on a issue immediately. If you want to add or fix something, open a pull request by following Laravel contribution guide.
Contributors
Credits
Specially Thanks to Appsero for giving me the opportunity to implement this great package.
License
The MIT License (MIT). Please see License File for more information.