Non-Permeable Membrane

    postgrest-url

    0.2.1 • Public • Published

    postgrest-url Build Status codecov NPM Version NPM Downloads NPM License

    Build urls for PostgREST

    postgrest-url is a small library focused in the construction of urls for PostgREST. Based on query definition written in object notation the library outputs a safe url.

    Install

    $ npm install --save postgrest-url

    Usage

    var level = {
        'levels:level': {
            id: 'eq.1',
            limit: 10,
            offset: 3
        }
    };
    var zone = {
        'zones:zone': {
            id: 'eq.1',
            limit: 10,
            offset: 3
        }
    };
     
    url(level);
    // level?id=eq.1&limit=10&offset=3
     
    url(zone);
    // zone?id=eq.1&limit=10&offset=3
     
    url({
        space: {
            id: 'eq.1',
            select: ['*', level]
        }
    });
    // space?select=*,levels:level{*}&id=eq.1&level.id=eq.1&level.limit=10&level.offset=3
     
    url({
        space: {
            id: 'eq.1',
            select: ['*', level, zone]
        }
    });
     
    // space?select=*,levels:level{*},zones:zone{*}&id=eq.1&level.id=eq.1&level.limit=10&level.offset=3&zone.id=eq.1&zone.limit=10&zone.offset=3
     
    url({
        space: {
            id: 'eq.1',
            select: ['*', {
                'levels:level': {
                    id: 'eq.1',
                    limit: 10,
                    offset: 3,
                    order: 'age.asc',
                    select: ['*', zone]
                }
            }]
        }
    });
    // space?select=*,levels:level{*,zones:zone{*}}&id=eq.1&level.id=eq.1&level.limit=10&level.offset=3&level.order=age.asc&level.zone.id=eq.1&level.zone.limit=10&level.zone.offset=3

    Check the code in the test folder for more.

    Build and test

    npm test -s
    # run tests on changes 
    npm run watch -- -s

    Release

    https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#commit
    https://github.com/conventional-changelog/standard-version

    npm run commmit -- -a
    npm run release

    Todo

    • add docs and examples
    • urlencode where necessary
    • jsonb stuff
    • add browser test to travis

    License

    MIT © Hugo Dias

    Install

    npm i postgrest-url

    DownloadsWeekly Downloads

    15

    Version

    0.2.1

    License

    MIT

    Unpacked Size

    20.2 kB

    Total Files

    7

    Last publish

    Collaborators

    • hugomrdias