Skip to content

馃摙 Optimizations, new clauses and more control

Compare
Choose a tag to compare
@rakibtg rakibtg released this 12 Aug 12:40

SleekDB 1.5.0 comes with few important optimizations and with other features that will make it more easier to manage data. This is a recommended update if you are using an older version of SleekDB.

鉁岋笍 No breaking changes from 1.0.3 to 1.5.0

  • 馃挭 Improving document discovery process
    Starting from version 1.5.0 SleekDB will discover new documents without affecting the _id serializer, that means it will need to do a lot less work than before. That makes it more faster less memory hungry than ever before.
  • 馃悕 orWhere() clause method
    It will work as the OR condition of SQL. SleekDB supports multiple orWhere as object chain.
    $user = $usersDB->where( 'products.totalSaved', '>', 10 )
        ->orWhere( 'products.totalBought', '>', 20 )
        ->orWhere( 'products.shipped', '=', 1 )
        ->fetch();
  • 馃槏 in() clause method
    It work like the IN clause of SQL. SleekDB supports multiple in() as object chain for different fields.
    $user = $usersDB
        ->in('country', ['BD', 'CA', 'SE', 'NA'])
        ->in('products.totalSaved', [100, 150, 200])
        ->fetch();
  • 馃槑 notIn() clause method
    It works as the opposite of in() method.
    It will filter out all documents that has particular data items from the given array.
    SleekDB supports multiple notIn as object chain for different fields.
    $user = $usersDB
        ->notIn('country', ['IN', 'KE', 'OP'])
        ->notIn('products.totalSaved', [100, 150, 200])
        ->fetch();
  • 馃 Keeping Query State
    If you want to keep the condition parameters for query and perform additional operations then you may want to use the keepConditions() method.
    Here is an example showing how you may fetch data and then update on the discovered documents without running an additional query:
    // Find documents.
    $result = $usersDB
        ->keepConditions() // Won't reset the active query state.
        ->where('products.totalBought', '>', 0)
        ->where('products.totalSaved', '>', 0);
    
    // Fetch data.
    $result->fetch();
    
    // Update matched documents.
    $result->update([
        'someRandomData' => '123',
    ]);