ballerina/dataservice Ballerina library

0.1.0

Overview

The ballerina/dataservice package supports the data services that bal persist generates from a persist model. A data service exposes the entities of the model over a protocol such as HTTP, with no hand-written service code.

The package holds the @dataservice:Expose annotation, which selects the entities a data service exposes and the actions each allows, and the protocol-neutral runtime that generated services call.

Key Features

  • @dataservice:Expose selects the entities a data service exposes, the actions each allows and their scopes
  • @dataservice:ReadOnly, @dataservice:Immutable and @dataservice:Internal control what the service does with a field
  • A compiler plugin checks the annotations while the model is edited and when bal persist generates
  • A protocol-neutral runtime for filters, sorting, paging, fields, relation reads, value conversions and the error body

Quick start

  1. Add the persist entry with a data service to the package:

    Copy
    bal persist add --datastore h2 --dataservice http
  2. Annotate each entity to expose in persist/model.bal. A bare annotation allows every action:

    Copy
    import ballerina/dataservice;
    import ballerina/persist as _;
    
    @dataservice:Expose
    type Employee record {|
        readonly int id;
        string name;
    |};
    
    @dataservice:Expose {operations: [dataservice:READ]}
    type Department record {|
        readonly int id;
        string name;
    |};
  3. Build the package. The persist client and the data service are generated into generated/:

    Copy
    bal build

For the details, see the specification.

Import

import ballerina/dataservice;Copy

Other versions

0.1.0

Metadata

Released date: about 19 hours ago

Version: 0.1.0

License: Apache-2.0


Security

No known vulnerabilities in libraries

Checked on 2026-11-20 via OSV.dev


Compatibility

Platform: java25

Ballerina version: 2201.14.0

GraalVM compatible: Yes


Pull count

Total: 13

Current verison: 13


Weekly downloads


Source repository


Keywords

dataservice

persist

data

Type/Library

Area/Database

Name/Data Service


Contributors