DB Query
GET collection
Example of getting the whole posts collection
DB::table('posts')->all();
Example of getting a single collection by _id
_id | String
DB::table('posts')->where('_id',$id)->get();
Example of getting a single collection by key and value
key | String value | String
DB::table('posts')->where('key',$value)->get();
ADD collection
Example of adding a new post collection
$request_data | Array
DB::where('posts')->save($request_data);
UPDATE collection
Example of updating a collection.
This usually use with $router->put() method
$request_data | Array
Note - $request_data must include _id
field
DB::where('posts')->save($request_data);
DELETE collection
Example of deleting a collection
$id | String
DB::where('posts')->delete($id);
Last updated
Was this helpful?