Complete reference for all noneDB methods and operations.
Version: 3.1.0
- Database Operations
- CRUD Operations
- Query Operations
- Aggregation
- Sharding
- Field Indexing
- Spatial Indexing
- Utility Methods
Create a new database.
$result = $db->createDB("users");
// Returns: true (created) or false (already exists)Check if database exists. Creates it if autoCreateDB is true.
$exists = $db->checkDB("users");
// Returns: true or falseList databases.
// Names only
$names = $db->getDBs(false);
// ["users", "posts", "comments"]
// With metadata
$dbs = $db->getDBs(true);
// [
// ["name" => "users", "createdTime" => 1703123456, "size" => "2,5 KB"],
// ...
// ]
// Single database info
$info = $db->getDBs("users");
// ["name" => "users", "createdTime" => 1703123456, "size" => "2,5 KB"]Insert one or more records.
// Single record
$result = $db->insert("users", ["name" => "John", "email" => "john@test.com"]);
// ["n" => 1]
// Multiple records
$result = $db->insert("users", [
["name" => "John"],
["name" => "Jane"]
]);
// ["n" => 2]
// With nested data
$result = $db->insert("users", [
"name" => "John",
"address" => ["city" => "Istanbul", "country" => "Turkey"]
]);Errors:
// Reserved field
$db->insert("users", ["key" => "value"]);
// ["n" => 0, "error" => "You cannot set key name to key"]
// Invalid data
$db->insert("users", "not an array");
// ["n" => 0, "error" => "insert data must be array"]Find records matching filter.
// All records
$all = $db->find("users", 0);
$all = $db->find("users", []);
// By field
$results = $db->find("users", ["name" => "John"]);
// By multiple fields (AND)
$results = $db->find("users", ["name" => "John", "active" => true]);
// By key
$results = $db->find("users", ["key" => 0]);
$results = $db->find("users", ["key" => [0, 1, 2]]);Returns: Array of records with key field added.
Update matching records.
// By field
$result = $db->update("users", [
["name" => "John"], // Filter
["set" => ["active" => true]] // Updates
]);
// ["n" => 1]
// By key
$result = $db->update("users", [
["key" => [0, 1, 2]],
["set" => ["status" => "inactive"]]
]);
// All records
$result = $db->update("users", [
[],
["set" => ["updated_at" => time()]]
]);Delete matching records.
// By field
$result = $db->delete("users", ["name" => "John"]);
// ["n" => 1]
// By key
$result = $db->delete("users", ["key" => [0, 2]]);
// All records
$result = $db->delete("users", []);$query = $db->query("users");| Method | Description |
|---|---|
where($filters) |
AND filter with operator support |
orWhere($filters) |
OR filter |
whereIn($field, $values) |
Value in array |
whereNotIn($field, $values) |
Value not in array |
whereNot($filters) |
Not equal |
like($field, $pattern) |
Pattern match |
notLike($field, $pattern) |
Pattern not match |
between($field, $min, $max) |
Range (inclusive) |
notBetween($field, $min, $max) |
Outside range |
search($term, $fields) |
Full-text search |
$db->query("users")->where([
'age' => ['$gt' => 18], // Greater than
'age' => ['$gte' => 18], // Greater than or equal
'age' => ['$lt' => 65], // Less than
'age' => ['$lte' => 65], // Less than or equal
'role' => ['$ne' => 'guest'],// Not equal
'role' => ['$eq' => 'admin'],// Equal (explicit)
'status' => ['$in' => ['active', 'pending']], // In array
'status' => ['$nin' => ['banned', 'deleted']], // Not in array
'email' => ['$exists' => true], // Field exists
'name' => ['$like' => 'John'], // Pattern match
'email' => ['$regex' => '@gmail.com$'], // Regex
'tags' => ['$contains' => 'featured'] // Array/string contains
]);| Method | Description |
|---|---|
select($fields) |
Include only specified fields |
except($fields) |
Exclude specified fields |
sort($field, $order) |
Sort results |
limit($count) |
Limit results |
offset($count) |
Skip records |
join($db, $localKey, $foreignKey) |
Join databases |
groupBy($field) |
Group results |
having($aggregate, $op, $value) |
Filter groups |
| Method | Returns |
|---|---|
get() |
All matching records |
first() |
First record or null |
last() |
Last record or null |
count() |
Number of matches |
exists() |
Boolean |
sum($field) |
Sum of field |
avg($field) |
Average of field |
min($field) |
Minimum value |
max($field) |
Maximum value |
distinct($field) |
Unique values |
update($set) |
Update matches |
delete() |
Delete matches |
$total = $db->count("users", 0);
$active = $db->count("users", ["active" => true]);$totalSalary = $db->sum("users", "salary");
$avgAge = $db->avg("users", "age");
$filteredSum = $db->sum("orders", "amount", ["status" => "paid"]);$minPrice = $db->min("products", "price");
$maxScore = $db->max("scores", "points");$cities = $db->distinct("users", "city");
// ["Istanbul", "Ankara", "Izmir"]$info = $db->getShardInfo("users");
// [
// "sharded" => true,
// "shards" => 5,
// "totalRecords" => 45000,
// "deletedCount" => 150,
// "shardSize" => 10000,
// "nextKey" => 45150
// ]$result = $db->compact("users");
// ["success" => true, "freedSlots" => 150, ...]$result = $db->migrate("users");
// ["success" => true, "status" => "migrated"]$db->isShardingEnabled(); // true/false
$db->getShardSize(); // 10000$result = $db->createFieldIndex("users", "email");
// ["success" => true]$exists = $db->hasFieldIndex("users", "email");
// true/false$result = $db->dropFieldIndex("users", "email");$result = $db->createSpatialIndex("locations", "coords");
// ["success" => true, "indexed" => 150]
// Records with invalid/missing GeoJSON are skipped (not indexed)
// Always check 'indexed' count to verify$exists = $db->hasSpatialIndex("locations", "coords");
// true/false$indexes = $db->getSpatialIndexes("locations");
// ["coords", "boundary"]$result = $db->dropSpatialIndex("locations", "coords");$result = $db->rebuildSpatialIndex("locations", "coords");
// Drops and recreates the spatial index from existing data$nearby = $db->withinDistance("locations", "coords", 28.97, 41.00, 5000);
// Records within 5000 meters (5km)$inArea = $db->withinBBox("locations", "coords", 28.97, 41.00, 29.00, 41.03);$closest = $db->nearest("locations", "coords", 28.97, 41.00, 5);
// 5 nearest records$polygon = ['type' => 'Polygon', 'coordinates' => [...]];
$inside = $db->withinPolygon("locations", "coords", $polygon);$result = $db->validateGeoJSON($geometry);
// ["valid" => true] or ["valid" => false, "error" => "..."]$sorted = $db->sort($results, "name", "asc");
$sorted = $db->sort($results, "created_at", "desc");$limited = $db->limit($results, 10);$first = $db->first("users");
$last = $db->last("users", ["active" => true]);$exists = $db->exists("users", ["email" => "test@test.com"]);
// true/false$results = $db->like("users", "email", "gmail"); // Contains
$results = $db->like("users", "name", "^John"); // Starts with
$results = $db->like("users", "name", "son$"); // Ends with$results = $db->between("products", "price", 100, 500);
$results = $db->between("products", "price", 100, 500, ["active" => true]);noneDB::clearStaticCache();
noneDB::disableStaticCache();
noneDB::enableStaticCache();noneDB::configExists(); // Check config file
noneDB::getConfigTemplate(); // Get template path
noneDB::clearConfigCache(); // Clear cached config
noneDB::setDevMode(true); // Enable dev mode
noneDB::isDevMode(); // Check dev mode