Harper Dev Center Logo
Search

Introducing HarperDB 4.3

NEW | March 2024
Hide Details
Show Details

Release Highlights

Full Release Note

Download Now

Ship Faster, Stress Less

Save engineering time with a fused core technology and pre-built components that give developers complete control while enhancing  composability.

Auto Generate Endpoints from Schemas

By using a GraphQL schema, it’s easy to create database tables, indexes, relationships, and REST endpoints.
Documentation
// Adding the @export directive when defining a table creates a REST endpoint 

type Owner @table @export { 
    name: String
    age: Int 
    address: String 
    phone: String 
    email: String 
    dogId: ID @indexed # Foreign key referencing the Pet table (Dog ID)
    dog: [Dog] @relationship(from: dogId) # Relationship to the Dog table, linked by dogId
}...

type Dog @table @export {
    id: ID @primaryKey # The unique identifier for each Dog (Primary Key)
    name: String 
    breed: String 
    age: Int    
}  

// The REST endpoint can be accessed using the following URL when running a Harper application component on your local machine:
curl 'http://localhost:9926/Owner/'

Custom Endpoints in Minutes

Harper’s application component provides tremendous flexibility and control over how data is accessed and modified in Harper.
Documentation
// The code below retrieves a dog's information from the database using the DogAge class, which extends the Dog model to provide functionality for converting a dog's age to human age.

// This class retrieves a dog's information from the database and calculates its equivalent age in human years. 

const { Dog } = tables;

// Convert dog age to human age
export class DogAge extends Dog {
    get() {
        const dog = super.get(); // Get the dog from the database
        const humanAge = dog.age * 7; // Convert dog age to human age
        return { ...dog, humanAge }; // Return the dog with human age
    }
}

Simple Client to Data Interactions

Easilyquery REST or custom endpoints – no drivers or third-party libraries are required.
Documentation
// Add new data to the database

Request:

curl -X POST http://localhost:9926/Owner/ \
-H "Content-Type: application/json" \
-d '{
    "id": 1,
    "name": "harper",
    "breed": "good boy",
    "age": 5
}'

Recent Tutorials