Options
All
  • Public
  • Public/Protected
  • All
Menu

Class NamingConvention

A NamingConvention instance is used to specify the naming conventions under which a MetadataStore will translate property names between the server and the javascript client.

The default NamingConvention does not perform any translation, it simply passes property names thru unchanged.

dynamic

Hierarchy

  • NamingConvention

Index

Constructors

constructor

  • NamingConvention constructor

     // A naming convention that converts the first character of every property name to uppercase on the server
     // and lowercase on the client.
     var namingConv = new NamingConvention({
         serverPropertyNameToClient: function(serverPropertyName) {
             return serverPropertyName.substr(0, 1).toLowerCase() + serverPropertyName.substr(1);
         },
         clientPropertyNameToServer: function(clientPropertyName) {
             return clientPropertyName.substr(0, 1).toUpperCase() + clientPropertyName.substr(1);
         }
     });
     var ms = new MetadataStore({ namingConvention: namingConv });
     var em = new EntityManager( { metadataStore: ms });
    

    Parameters

    Returns NamingConvention

Properties

clientPropertyNameToServer

clientPropertyNameToServer: (nm: string, context?: any) => string

Function that takes a client property name add converts it into a server side property name. Read Only

Type declaration

    • (nm: string, context?: any): string
    • Parameters

      • nm: string
      • Optional context: any

      Returns string

name

name: string

The name of this NamingConvention. Read Only

serverPropertyNameToClient

serverPropertyNameToClient: (nm: string, context?: any) => string

Function that takes a server property name add converts it into a client side property name. Read Only

Type declaration

    • (nm: string, context?: any): string
    • Parameters

      • nm: string
      • Optional context: any

      Returns string

Static camelCase

camelCase: NamingConvention = new NamingConvention({name: "camelCase",serverPropertyNameToClient: (serverPropertyName) => {return serverPropertyName.substr(0, 1).toLowerCase() + serverPropertyName.substr(1);},clientPropertyNameToServer: (clientPropertyName) => {return clientPropertyName.substr(0, 1).toUpperCase() + clientPropertyName.substr(1);}})

The "camelCase" naming convention - This implementation only lowercases the first character of the server property name but leaves the rest of the property name intact. If a more complicated version is needed then one should be created via the ctor.

Static defaultInstance

defaultInstance: NamingConvention = new NamingConvention(NamingConvention.none)

The default value whenever NamingConventions are not specified.

Static none

none: NamingConvention = new NamingConvention({name: "noChange",serverPropertyNameToClient: (serverPropertyName) => {return serverPropertyName;},clientPropertyNameToServer: (clientPropertyName) => {return clientPropertyName;}})

/** A noop naming convention - This is the default unless another is specified.

Methods

setAsDefault

  • setAsDefault(): any
  • Sets the 'defaultInstance' by creating a copy of the current 'defaultInstance' and then applying all of the properties of the current instance. The current instance is returned unchanged.

     var namingConv = new NamingConvention({
         serverPropertyNameToClient: function(serverPropertyName) {
             return serverPropertyName.substr(0, 1).toLowerCase() + serverPropertyName.substr(1);
         },
         clientPropertyNameToServer: function(clientPropertyName) {
             return clientPropertyName.substr(0, 1).toUpperCase() + clientPropertyName.substr(1);
         }
     });
     namingConv.setAsDefault();
    

    Returns any

Generated using TypeDoc