furystack-core
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-alpha-15 • Public • Published

furystack-core

Greenkeeper badge

Build Status codecov Codacy Badge

FuryStack framework, core package.

Model declaration with @PrimaryKey, @Property and @ForeignKey decorators:

class RefExample {
    @PrimaryKey
    public Id;
 
    @Property
    public Value: string;
}
 
class MyModel {
    @PrimaryKey
    public Id: number;
 
    @Property
    public MyPropertyA: string;
 
    @Property
    public MyPropertyB: string;
 
    @ForeignKey(RefExample, 'RefExample')
    public RefExampleId: number;
    public RefExample: RefExample;
}

Accessing model metadata via Global ModelDescriptorStore, usage:

const descriptor = ModelDescriptorStore.GetDescriptor(MyModel);
/*
 
descriptor.Object = {constructor: class MyModel { … }}
 
descriptor.Entries = [
  PrimaryKeyDescriptorEntry {PrimaryKey: "Id"}
  ODataPropertyDesrciptorEntry {PropertyName: "MyPropertyA", EdmType: 0}
  ODataPropertyDesrciptorEntry {PropertyName: "MyPropertyB", EdmType: 0}
  ForeignKeyDescriptorEntry {ForeignKeyField: "RefExample", ReferenceName: "RefExample"}
]
 
descriptor..PrimaryKey = PrimaryKeyDescriptorEntry {PrimaryKey: "Id"}
 
descriptor.Properties = [
  ODataPropertyDesrciptorEntry {PropertyName: "MyPropertyA", EdmType: 0}
  ODataPropertyDesrciptorEntry {PropertyName: "MyPropertyB", EdmType: 0}
]
 
descriptor.ForeignKeys = [
  ForeignKeyDescriptorEntry {ForeignKeyField: "RefExample", ReferenceName: "RefExample"}
]
 
*/

Setup and endpoint with the EndpointBuilder class:

    const builder = new EndpointBuilder('api');
 
    builder.EntityType(MyModel);
    builder.EntityType(RefExample);
 
    builder.EntitySet(MyModel, 'mymodels');

Package Sidebar

Install

npm i furystack-core

Weekly Downloads

1

Version

1.0.0-alpha-15

License

MIT

Unpacked Size

116 kB

Total Files

119

Last publish

Collaborators

  • gallayb
  • gallayl