Skip to main content

Crate product_os_service_handler

Crate product_os_service_handler 

Source
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 support
  • sqlite_store - Enable SQLite database support

§Architecture

The handler follows a layered architecture:

  1. HTTP Layer: Route handlers process HTTP requests
  2. Conversion Layer: Transform between JSON and database formats
  3. Database Layer: Execute queries via ProductOSRelationalStore

Structs§

ProductOSServiceHandler
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

Attribute Macros§

async_trait