All Projects → formapro → yadm

formapro / yadm

Licence: MIT License
An efficient way to treat MongoDB in PHP. Extremely fast persistence and hydration.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to yadm

nuxt-speedkit
nuxt-speedkit will help you to improve the lighthouse performance score (100/100) of your website.
Stars: ✭ 401 (+377.38%)
Mutual labels:  hydration
vue-vuex-persist
vuex持久化插件
Stars: ✭ 16 (-80.95%)
Mutual labels:  persistence
FreeSolv
Experimental and calculated small molecule hydration free energies
Stars: ✭ 64 (-23.81%)
Mutual labels:  hydration
linper
Linux Persistence Toolkit
Stars: ✭ 20 (-76.19%)
Mutual labels:  persistence
Persistence
Plugin para almacenar datos de forma persistente en Godot Engine 3
Stars: ✭ 20 (-76.19%)
Mutual labels:  persistence
microstream
High-Performance Java-Native-Persistence. Store and load any Java Object Graph or Subgraphs partially, Relieved of Heavy-weight JPA. Microsecond Response Time. Ultra-High Throughput. Minimum of Latencies. Create Ultra-Fast In-Memory Database Applications & Microservices.
Stars: ✭ 283 (+236.9%)
Mutual labels:  persistence
sched
⏳ a high performance reliable task scheduling package in Go.
Stars: ✭ 46 (-45.24%)
Mutual labels:  persistence
stardust-SDK
Stardust SDK and sample app for Unity
Stars: ✭ 23 (-72.62%)
Mutual labels:  persistence
vue-auto-storage
🍻 An automatic storage plugin for Vue2, persist the data with localStorage.
Stars: ✭ 84 (+0%)
Mutual labels:  persistence
apart
Get all your structure and rip it apart.
Stars: ✭ 26 (-69.05%)
Mutual labels:  persistence
android-room-example
Android Kotlin app showcasing the Room persistence library
Stars: ✭ 45 (-46.43%)
Mutual labels:  persistence
nuxt-delay-hydration
Improve your Nuxt.js v2 Google Lighthouse score by delaying hydration ⚡️
Stars: ✭ 135 (+60.71%)
Mutual labels:  hydration
react-hydration-on-demand
Hydrate your React components only when you need to
Stars: ✭ 94 (+11.9%)
Mutual labels:  hydration
PlacenoteSDK-Unity
Placenote SDK and sample app for Unity
Stars: ✭ 78 (-7.14%)
Mutual labels:  persistence
GitHubSearch
GitHub iOS client with minimum third-party dependencies.
Stars: ✭ 34 (-59.52%)
Mutual labels:  persistence
js-coalaip
Javascript implementation for COALA IP
Stars: ✭ 18 (-78.57%)
Mutual labels:  persistence
acolyte
🐯 Mockup/testing JDBC & MongoDB driver (or Chmeee's son on the Ringworld).
Stars: ✭ 58 (-30.95%)
Mutual labels:  persistence
HouraiOptions
Simplified and automatic game option creation for Unity3D games.
Stars: ✭ 18 (-78.57%)
Mutual labels:  persistence
perseverance
Make your functions 💪 resilient and 🚥 fail-fast to 💩 failures or ⌚ delays
Stars: ✭ 12 (-85.71%)
Mutual labels:  persistence
bee-apm
BeeAPM is a distributed tracing system and APM ( Application Performance Monitoring )
Stars: ✭ 137 (+63.1%)
Mutual labels:  persistence

Yadm is the fastest MongoDB ODM.

Build Status

The schema less ODM. It gives you the fastest hydration and persistent. Based on formapro/values lib.

Install

$ composer require formapro/yadm "mikemccabe/json-patch-php:dev-master as 0.1.1"

Storage example

Let's say we have an order model:

<?php

namespace Acme;

use function Formapro\Values\set_value;
use function Formapro\Values\get_value;

class Price
{
    private $values = [];
    
    public function setCurrency(string $value): void
    {
        set_value($this, 'currency', $value);
    }
    
    public function getCurrency(): string 
    {
        return get_value($this, 'currency');
    }
    
    public function setAmount(int $value): void
    {
        set_value($this, 'amount', $value);
    }
    
    public function getAmount(): string 
    {
        return get_value($this, 'amount');
    }
}
<?php
namespace Acme;

use function Formapro\Values\set_value;
use function Formapro\Values\get_value;
use function Formapro\Values\set_object;
use function Formapro\Values\get_object;

class Order
{
    private $values = [];
    
    public function setNumber(string $number): void
    {
        set_value($this, 'number', $number);
    }
    
    public function getNumber(): string 
    {
        return get_value($this, 'number');
    }
    
    public function setPrice(Price $price): void
    {
        set_object($this, 'price', $price);
    }
    
    public function getPrice(): Price
    {
        return get_object($this, 'price', Price::class);
    }
}
<?php
namespace Acme;

use MongoDB\Client;
use Formapro\Yadm\Hydrator;
use Formapro\Yadm\Storage;

$collection = (new Client())->selectCollection('acme_demo', 'orders');
$hydrator = new Hydrator(Order::class);
$storage = new Storage($collection, $hydrator);

$price = new Price();
$price->setAmount(123); # 1.23 USD
$price->setCurrency('USD');

$order = new Order();
$order->setNumber(1234);
$order->setPrice($price);

$storage->insert($order);

$foundOrder = $storage->find(['_id' => get_object_id($order)]);
$foundOrder->setNumber(4321);
$storage->update($foundOrder);

$storage->delete($foundOrder);

MongoDB special types usage

<?php
namespace Acme;

use MongoDB\Client;
use Formapro\Yadm\Hydrator;
use Formapro\Yadm\Storage;
use Formapro\Yadm\ConvertValues;
use Formapro\Yadm\Type\UuidType;
use Formapro\Yadm\Type\UTCDatetimeType;
use Formapro\Yadm\Uuid;
use function Formapro\Values\set_value;
use function Formapro\Values\get_value;

$convertValues = new ConvertValues([
    'id' => new UuidType(),
    'createdAt' => new UTCDatetimeType(),
]);

$collection = (new Client())->selectCollection('acme_demo', 'orders');
$hydrator = new Hydrator(Order::class);
$storage = new Storage($collection, $hydrator, null, null, $convertValues);
 

$order = new Order();
set_value($order, 'id', Uuid::generate()->toString());
set_value($order, 'createdAt', (new \DateTime())->format('U'));

$storage->insert($order);

$id = get_value($order, 'id');

// find by uuid
$anotherOrder = $storage->findOne(['id' => new Uuid($id)]);

// do not update id if not changed
$storage->update($anotherOrder);

// update on change
set_value($anotherOrder, 'id', Uuid::generate()->toString());
$storage->update($anotherOrder);

Other examples

In formapro/values repo you can find examples on how to build simple objects, object trees, hydrate and retrive data from\to object.

Benchmarks

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].