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.
This package requires Laravel 9.x & PHP 8.1 as a minimum.
You can install the package via composer:
composer require affordablemobiles/eloquent-datastore
If you are using Laravel Package Auto-Discovery, you don't need you to manually add the ServiceProvider.
If you don't use auto-discovery, add the below ServiceProvider to the $providers
array in config/app.php
file.
AffordableMobiles\EloquentDatastore\DatastoreServiceProvider::class,
- Read data using query builder.
- Read data using Eloquent model.
- Insert data using Eloquent model.
- Update data using Eloquent model.
- Delete data.
- Keys only queries.
- Auto-generated primary key.
- Read multiple pages of data with Datastore cursors.
- Batch update from Eloquent collection.
- Cursor Paginate.
- Ancestor key relations.
- Datastore Namespaces (Multi-Tenancy).
You need to add datastore
connection in config/database.php
file.
'connections' => [
...
'datastore' => [
'driver' => 'datastore',
'transport' => env('DATASTORE_TRANSPORT', 'grpc'),
],
...
],
You need to extend AffordableMobiles\EloquentDatastore\Eloquent\Model
class instead of Laravel's default Eloquent model class.
Example-
<?php
namespace App\Models;
use AffordableMobiles\EloquentDatastore\Eloquent\Model;
class Project extends Model
{
// Your works here
}
Example-
DB::connection('datastore')
->table('projects')
->where('project_id', '>', 5)
->skip(3)
->take(5)
->get();
It will return a collection.
-
connection
-
table
-
from
-
namespace
(Datastore Namespace: Multi Tenancy) -
select
(for projection query) -
kind
(same as table) -
where
(Available: = , > , < , >= , <= ) -
limit
/take
-
skip
-
orderBy
-
distinct
-
get
-
pluck
-
exists
-
count
-
simplePaginate
-
paginate
(works same as simplePaginate) -
first
-
delete
-
insert
-
_upsert
(different and incompatible with defaultupsert
) -
find
/lookup
-
chunk
/chunkMap
/each
-
lazy
/cursor
You can contribute by reporting bugs, fixing bugs, submitting and reviewing pull requests.
Go to issues section, and you can start working on an issue immediately.
The MIT License (MIT). Please see License File for more information.