Still in beta. May be called Pragmalang?

Website

import hooks from "./hooks.js"

@user
@onWrite(hooks.validateUser)
@onWrite(hooks.setFullName)
model User {
  username: String @publicCredential @priamry
  password: String @secretCredential
  firstName: String
  lastName: String
  fullName: String
  age: Int
}

allow CREATE User

hooks.js is a JavaScript file containing two definitions:

const validateUser = user => {
  if(user.age < 18) {
    throw new Error("Age must be over 18")
  }
  return user
}

const setFullName = user => 
  ({...user, fullName: user.firstName + " " + user.lastName})


Tags: language  

Last modified 07 October 2024