All Projects → cybrox → crunchdb

cybrox / crunchdb

Licence: MIT license
A simple JSON based database system written in PHP. Useful for smaller applications.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to crunchdb

flutter file utils
Flutter package for managing files on Android
Stars: ✭ 35 (+9.38%)
Mutual labels:  filesystem
python-task-queue
Asynchronous serverless task queue with timed leasing of tasks. Threaded implementations for SQS and local filesystem.
Stars: ✭ 24 (-25%)
Mutual labels:  filesystem
paragon apfs sdk ce
Paragon APFS SDK Free
Stars: ✭ 97 (+203.13%)
Mutual labels:  filesystem
xv6-file-system-visualizer
Online Visualizer for xv6 File System Image
Stars: ✭ 33 (+3.13%)
Mutual labels:  filesystem
nestjs-storage
Nestjs file system / file storage module wrapping flydrive
Stars: ✭ 92 (+187.5%)
Mutual labels:  filesystem
RxLogs
An Android & Kotlin Reactive Advanced Logging Framework.
Stars: ✭ 12 (-62.5%)
Mutual labels:  filesystem
flysystem-curlftp
Flysystem Adapter for the FTP with cURL implementation
Stars: ✭ 36 (+12.5%)
Mutual labels:  filesystem
glob
Pure Nim library for matching file paths against Unix style glob patterns.
Stars: ✭ 58 (+81.25%)
Mutual labels:  filesystem
yggdrasil
No description or website provided.
Stars: ✭ 26 (-18.75%)
Mutual labels:  filesystem
lustre-release
Mirror of official Lustre development repository http://git.whamcloud.com/
Stars: ✭ 35 (+9.38%)
Mutual labels:  filesystem
emojifs
emojifs is a FUSE filesystem that allows you to manipulate custom emojis on your various Slacks and Discords
Stars: ✭ 30 (-6.25%)
Mutual labels:  filesystem
OpenGnsys
OpenGnsys (pronounced Open Genesis) is a free and open source project that provides tools for managing and deploying different operating systems.
Stars: ✭ 15 (-53.12%)
Mutual labels:  filesystem
gravity
User-space deniable data encryption client.
Stars: ✭ 89 (+178.13%)
Mutual labels:  filesystem
apfs-clone-checker
An utility to check if two files are clones in macOs APFS.
Stars: ✭ 30 (-6.25%)
Mutual labels:  filesystem
kodbox
kodbox is a file manager for web. It is a newly designed product based on kodexplorer. It is also a web code editor, which allows you to develop websites directly within the web browser.You can run kodbox either online or locally,on Linux, Windows or Mac based platforms
Stars: ✭ 1,188 (+3612.5%)
Mutual labels:  filesystem
dropbox-fs
📦 Node FS wrapper for Dropbox
Stars: ✭ 35 (+9.38%)
Mutual labels:  filesystem
libusbhsfs
USB Mass Storage Class Host + Filesystem Mounter static library for Nintendo Switch homebrew applications.
Stars: ✭ 81 (+153.13%)
Mutual labels:  filesystem
-LibraryOS-Exokernel Implementation
Exokernel is one of the major sources for container and library OS techniques.
Stars: ✭ 41 (+28.13%)
Mutual labels:  filesystem
nvfuse
NVMe based File System in User-space
Stars: ✭ 81 (+153.13%)
Mutual labels:  filesystem
ksmbd
ksmbd kernel server(SMB/CIFS server)
Stars: ✭ 181 (+465.63%)
Mutual labels:  filesystem

crunchDB - Yet another json database?

Yes, crunchDB is a simple database system written in PHP that is based on storing information in multiple json files. Each json file represents a table and can be accessed and modified via crunchDB. Well, there already are other json based systems, so why creating another one? Actually, though there are a lot of good systems like this out there, I haven't really found anything that offered all the features I wanted in a nice and clear way. Though crunchDB is very simple at the moment, It might get additional functionality to make it more powerful. In it's current state, it is awesome to use for smaller projects like a little chat client. - That's what I wrote it for.

Project structure

This repository contains a src directory which contains all the chrunchDB files. Also, there is an example file to demonstrate some actions. You can download and run this file, it will delete all the changes it made by dropping its created tables after testing.

Features

So, obviously, crunchDB needs to have some sort of functionality. It would be pretty useless otherwise, wouldn't it?
Here's a list of all functions that are currently implemented.

$cdb = new CrunchDB('./db/', 'json', 'rw') Initialize crunchdb with the following parameters:

  • directory - The path to the directory where all the json files will be stored in.
  • extension - The extension of the db files. (This parameter is optional, it is set to json as default)
  • db mode - The database access mode. Can be read(r) or (rw). (Not yet implemented!)

PLEASE NOTE: crunchDB does not currently support or handle file locking. Thus using it for anything more than simple internal tools (mainly anything with concurrent access, obviously) is highly discouraged!

Method Description
crunchDB->version() Return the current crunchDB version. Useful to see if everything is set up.
crunchDB->tables() List all tables (=files) that are present in this database (=directory).
crunchDB->table('name') Get the object of a crunchDB table cdbTable.
-- --
cdbTable->create() Create a table and its JSON file with the given name.
cdbTable->exists() Check whether or not a table (file) with the given name exists.
cdbTable->truncate() Truncate the given table object.
cdbTable->drop() Drop the given table object and delete its JSON file.
cdbTable->alter('name') Rename the table object's file and table to name.
cdbTable->raw() Get the raw json data of the table's content.
cdbTable->count() Count all rows in this table. This is equal to ->select('*')->count().
cdbTable->insert('data') Insert an array of data, crunchDB will not check it's structure!
cdbTable->select(*1) Select rows from the table, see explanation of *1 below! Returns resouce cdbRes
-- --
cdbRes->sort(*2) Sort rows in the resource, see explanation of *2 below!
cdbRes->sortfn('func') Sort rows in the resource via usort with a custom function (PHP 5.3+)
cdbRes->count() Count all the rows in this resource
cdbRes->fetch() Fetch all the rows in this resource
cdbRes->delete() Fetch all the rows in this resource from the table
cdbRes->update(*3) Update all the rows in this resource from the table, see explanation of *3 below

Parameter explanation

*1 SELECT Parameter

This is the multi-array parameter for select. You can add multiple keys to filter for, for example ['type', '==', 'user'] would search for all rows where the column type equals 'user'. Hereby, the first element is the key to search for, the second one the compare operator (<, <=, ==, >= or >), the third one the respective value to compare and the optional fourth parameter can be an 'and' or 'or'. You can also chain select parameters as following:

// Search for rows with the type `user` **OR** `admin
...->select(['type', '==', 'user'],['type', '==', 'admin'])->...

// Search for rows with the type `user` **AND** the `name` 'cybrox' 
...->select(['type', '==', 'user'],['name', '==', 'cybrox', 'and'])->...
*2 SORT Parameter

This is the multi-array parameter for sorting. You can add multiple keys to sort by, for exmaple ['name'] or ['name', SORT_DESC]. Each array can have up to 3 parameters, that being the column name to sort on (mandatory), either SORT_ASC or SORT_DESC (optional) and a projection function (optional).
You can also chain sort parameters as following:

// Sort by number descending and then by name descending.
...->sort(['type', SORT_DESC], ['name', SORT_DESC])->...
*3 UPDATE Parameter

This is the multi-array parameter for updating. You can add multiple key-vaule pairs to update here like ['name','cybrox']. You can chain as many fields in there as you want to change.

// Update type and name of a resource.
...->update(['type','admin'],['name','cybrox'])->...

Code examples

<?php

  use cybrox\crunchdb\crunchDB as crunchDB;
  $cdb = new crunchDB('./db/');

  $cdb->version();
  $cdb->table('cookies')->exists();
  $cdb->table('cookies')->create();
  $cdb->table('cakes')->create();
  $cdb->table('cakes')->alter('cheese');
  $cdb->tables();
  $cdb->table('cookies')->count();
  $cdb->table('cookies')->insert(array("type" => "chocolate", "is" => "nice"));
  $cdb->table('cookies')->insert(array("type" => "banana", "is" => "nice"));
  $cdb->table('cookies')->insert(array("type" => "strawberry", "is" => "ok"));
  $cdb->table('cookies')->raw();
  $cdb->table('cookies')->select('*')->fetch();
  $cdb->table('cookies')->select('*')->count();
  $cdb->table('cookies')->select(['type', '==', 'chocolate'])->fetch();
  $cdb->table('cookies')->select(['type', '==', 'chocolate'],['type', '==', 'banana', 'or'])->fetch();
  $cdb->table('cookies')->select(['type', '==', 'chocolate'],['type', '==', 'banana', 'and'])->count();
  $cdb->table('cookies')->select('*')->sort(['type'])->fetch();
  $cdb->table('cookies')->select(['type', '==', 'strawberry'])->delete();
  $cdb->table('cookies')->select(['type', '==', 'banana'])->update(['type', 'chocolate']);
  $cdb->table('cookies')->select('*')->fetch();

?>
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].