1.2.0 • Published 5 years ago

matilde v1.2.0

Weekly downloads
32
License
MIT
Repository
github
Last release
5 years ago

Matilde

A small library to transform JSON input to ~FBV~ syntax to work with Meadow endpoints.

From this:

--

To this!!

~~

Input Structure

[
    {...}, // See signature
    [ // nesting
        {...},
        {...},
        [ // even more nesting
            {...}
        ]
    ]
]

Signature

ArgumentTypeRequiredDescription
propStringYesThe property to query or sort on
qualifierStringYesA value from the list of qualifiers
valueStringYesValue to query with
opStringNoQuery using OR. Defaults to AND
sortString, BooleanNoSort on property ASC or DESC. Defaults to DESC if property is boolean and true

Usage

var inputData = [
    {
        prop: 'ID',
        qualifier: 'EQ',
        value: '1'
    },
    [
        {
            prop: 'Role',
            qualifier: 'LE',
            value: '4',
            op: 'OR'
        }, {
            prop: 'FirstName',
            qualifier: 'LK',
            value: 'Cesar',
            op: 'OR',
            sort: true
        },
        [
            {
                prop: 'LastName',
                qualifier: 'INN',
                values: ['Chavez', 'Vargas']
            }
        ]
    ]
]
// instantiate
var stuff = new Matilde();
// then manually init
stuff.init(inputData);

// or instantiate and init in one
var stuff = new Matilde(inputData);

// output
stuff.toString();

// outputs
"FBV~IDCompany~EQ~1~FOP~0~(~0~FBVOR~IDRole~EQ~4~FBVOR~FirstName~LK~one%25~FOP~0~(~0~FBL~LastName~INN~one,two~FCP~0~)~0~FCP~0~)~0~FSF~IDRole~ASC~0~FSF~FirstName~DESC~0"

Methods

.toString() returns "pew-ter" string

1.2.0

5 years ago

1.1.0

6 years ago

1.0.0

6 years ago