type-arango
Version:
ArangoDB Foxx decorators and utilities for TypeScript
25 lines (22 loc) • 771 B
text/typescript
import {Attribute, Collection, Document, Entities, Entity, Index, Route, RouteArg} from '../../../src' // type-arango
()
export class User extends Entity {
() // creates a hash index on User.email
(type => type.email()) // validates changes to user.email to be email addresses
email: string
()
name: string
}
// creates the collection Users
(of => User)
// creates three routes
.use('GET','POST','PATCH')
export class Users extends Entities {
// creates & documents a route on /users/custom/:user
.GET('custom/:user=number')
static GET_CUSTOM({param,error}: RouteArg){
const user = Users.find(param.user)
if(!user) return error('not found')
return user
}
}