Expand description
Product OS Service Handler
A FeathersJS-compatible service handler that provides CRUD operations for database tables through a REST API interface compatible with FeathersJS clients.
§Overview
This crate implements the FeathersJS service pattern, allowing seamless integration between Rust backends and FeathersJS clients. It provides:
- find: Query multiple records with pagination, filtering, and sorting
- get: Retrieve a single record by ID
- create: Insert new records into the database
- patch: Partially update existing records
- remove: Delete records from the database
- update: Full record replacement (not yet implemented)
§FeathersJS Compatibility
The service handler implements the standard FeathersJS query syntax including:
- Query operators:
$limit,$skip,$sort,$select - Comparison operators:
$lt,$lte,$gt,$gte,$ne,$in,$nin - Logical operators:
$or - Wildcard search with
*
§Example
use std::sync::Arc;
use parking_lot::Mutex;
use product_os_service_handler::ProductOSServiceHandler;
// Create a service for the "users" table
let service = ProductOSServiceHandler::new(
"users".to_string(),
"/api/users".to_string(),
"users".to_string(),
"id".to_string(),
controller
);
// Load the service into a router
let mut router = ProductOSRouter::new();
service.load_service(&mut router).await;§Features
postgres_store- Enable PostgreSQL database supportsqlite_store- Enable SQLite database support
§Architecture
The handler follows a layered architecture:
- HTTP Layer: Route handlers process HTTP requests
- Conversion Layer: Transform between JSON and database formats
- Database Layer: Execute queries via
ProductOSRelationalStore
Structs§
- ProductOS
Service Handler - Product OS Service Handler
Functions§
- object_
to_ query_ string - Converts a JSON object back to a query string
- query_
string_ to_ object - Converts a query string to a JSON object
- query_
to_ object - Converts a vector of query parameters to a JSON object