Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Add functionset declaration  #47

@minenwerfer

Description

@minenwerfer

What problem this addresses: The #1 problem with the language right now is the amount of code repetition when setting collection functions. If you have 15 collections with 5 functions each, and you add a new role to the access control, you'll have to manually change 15*5 = 75 lines.

This approach was inspired by SASS's mixin/include feature.

functionset Readable {
  get @expose
  getAll @expose
  count @expose
}

functionset Writable {
  insert @expose
  remove @expose
}

collection Person {
  properties {
    name str
  }
  functions {
    @include(Readable)
    @include(Writable)
    // @include(InvalidFunctionSet)
    //          ^ function set "InvalidFunctionSet" not found
  }
}

// same as
collection Person {
  properties {
    name str
  }
  functions {
    get @expose
    getAll @expose
    count @expose
    insert @expose
    remove @expose
  }
}

Both output:

export const person = defineCollection({
  // ....
  functions: {
    get,
    getAll,
    count,
    insert,
    remove,
  },
  exposedFunctions: {
    // ...
  },
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions