How to use the tubular-common.CompareOperators.NotEquals function in tubular-common

To help you get started, we’ve selected a few tubular-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github unosquare / tubular-nodejs / src / connectors / jsondata.spec.js View on Github external
it("skipping first 10 and taking 20", done => {
            const take = 20,
                filteredCount = 49;

            let request = new GridRequest([
                {
                    name: 'first_name', label: 'First Name', sortable: true, searchable: true, filter: {
                        name: '',
                        text: 'Ignacius',
                        argument: [],
                        operator: CompareOperators.NotEquals,
                        hasFilter: false
                    }
                },
                { name: 'last_name', label: 'Last Name', sortable: true, searchable: true },
                { name: 'address_id', label: 'Address Id', sortable: true, searchable: false }
            ],
                take,
                0);

            tubular.createGridResponse(request, data)
                .then(response => {
                    expect(response.counter).toBeDefined();
                    expect(response.totalRecordCount).toBe(totalRecordCount);
                    expect(response.filteredRecordCount).toBe(filteredCount);
                    expect(response.totalPages).toBe(Math.ceil(filteredCount / take));
                    expect(response.payload.length).toBe(take);
github unosquare / tubular-nodejs / src / connectors / knex.spec.js View on Github external
it("filters using NotEquals", done => {
            const take = 10,
                filteredCount = 598;

            let queryBuilder = knex.select('first_name', 'last_name', 'address_id').from('customer');

            let request = new GridRequest(
                [
                    {
                        name: 'first_name', label: 'First Name', sortable: true, searchable: true, filter: {
                            name: '',
                            text: 'Patricia',
                            argument: [],
                            operator: CompareOperators.NotEquals,
                            hasFilter: false
                        }
                    },
                    { name: 'last_name', label: 'Last Name', sortable: true, searchable: true },
                    { name: 'address_id', label: 'Address Id', sortable: true, searchable: false }
                ],
                take,
                0,
            );

            tubular.createGridResponse(request, queryBuilder)
                .then(response => {
                    expect(response.counter).toBeDefined();
                    expect(response.totalRecordCount).toBe(totalRecordCount);
                    expect(response.filteredRecordCount).toBe(filteredCount);
                    expect(response.totalPages).toBe(Math.ceil(filteredCount / take));
github unosquare / tubular-nodejs / src / connectors / knex.spec.js View on Github external
it("skipping first 10 and taking 20", done => {
            const take = 20,
                filteredCount = 598;

            let queryBuilder = knex.select('first_name', 'last_name', 'address_id').from('customer');

            let request = new GridRequest(
                [
                    {
                        name: 'first_name', label: 'First Name', sortable: true, searchable: true, filter: {
                            name: '',
                            text: 'Patricia',
                            argument: [],
                            operator: CompareOperators.NotEquals,
                            hasFilter: false
                        }
                    },
                    { name: 'last_name', label: 'Last Name', sortable: true, searchable: true },
                    { name: 'address_id', label: 'Address Id', sortable: true, searchable: false }
                ],
                take,
                0,
            );

            tubular.createGridResponse(request, queryBuilder)
                .then(response => {
                    expect(response.counter).toBeDefined();
                    expect(response.totalRecordCount).toBe(totalRecordCount);
                    expect(response.filteredRecordCount).toBe(filteredCount);
                    expect(response.totalPages).toBe(Math.ceil(filteredCount / take));
github unosquare / tubular-nodejs / src / connectors / jsondata.spec.js View on Github external
it("filters using NotEquals", done => {
            const take = 10,
                filteredCount = 49;

            let request = new GridRequest(
                [
                    {
                        name: 'first_name', label: 'First Name', sortable: true, searchable: true, filter: {
                            name: '',
                            text: 'Ignacius',
                            argument: [],
                            operator: CompareOperators.NotEquals,
                            hasFilter: false
                        }
                    },
                    { name: 'last_name', label: 'Last Name', sortable: true, searchable: true },
                    { name: 'address_id', label: 'Address Id', sortable: true, searchable: false }
                ],
                take,
                0,
            );

            tubular.createGridResponse(request, data)
                .then(response => {
                    expect(response.counter).toBeDefined();
                    expect(response.totalRecordCount).toBe(totalRecordCount);
                    expect(response.filteredRecordCount).toBe(filteredCount);
                    expect(response.totalPages).toBe(Math.ceil(filteredCount / take));
github unosquare / tubular-nodejs / src / connectors / knex.js View on Github external
filteredColumns.forEach(filterableColumn => {
        request.columns.find(column => column.name == filterableColumn.name).HasFilter = true;

        switch (filterableColumn.filter.operator) {
            case CompareOperators.Equals:
                subset = subset.where(filterableColumn.name, filterableColumn.filter.text);
                break;
            case CompareOperators.NotEquals:
                subset = subset.whereNot(filterableColumn.name, filterableColumn.filter.text);
                break;
            case CompareOperators.Contains:
                subset = subset.where(filterableColumn.name, 'LIKE', `%${filterableColumn.filter.text}%`);
                break;
            case CompareOperators.NotContains:
                subset = subset.whereNot(filterableColumn.name, 'LIKE', `%${filterableColumn.filter.text}%`);
                break;
            case CompareOperators.StartsWith:
                subset = subset.where(filterableColumn.name, 'LIKE', `${filterableColumn.filter.text}%`);
                break;
            case CompareOperators.NotStartsWith:
                subset = subset.whereNot(filterableColumn.name, 'LIKE', `${filterableColumn.filter.text}%`);
                break;
            case CompareOperators.EndsWith:
                subset = subset.where(filterableColumn.name, 'LIKE', `%${filterableColumn.filter.text}`);
github unosquare / tubular-nodejs / src / connectors / jsondata.js View on Github external
filteredColumns.forEach(filterableColumn => {

        request.columns.find(column => column.name == filterableColumn.name).hasFilter = true;

        switch (filterableColumn.filter.operator) {
            case CompareOperators.Equals:
                subset = subset.filter(row => row[filterableColumn.name] == filterableColumn.filter.text);
                break;
            case CompareOperators.NotEquals:
                subset = subset.filter(row => row[filterableColumn.name] != filterableColumn.filter.text);
                break;
            case CompareOperators.Contains:
                subset = subset.filter(row => row[filterableColumn.name].indexOf(filterableColumn.filter.text) >= 0);
                break;
            case CompareOperators.NotContains:
                subset = subset.filter(row => row[filterableColumn.name].indexOf(filterableColumn.filter.text) < 0);
                break;
            case CompareOperators.StartsWith:
                subset = subset.filter(row => row[filterableColumn.name].toLowerCase().startsWith(filterableColumn.filter.text));
                break;
            case CompareOperators.NotStartsWith:
                subset = subset.filter(row => !row[filterableColumn.name].toLowerCase().startsWith(filterableColumn.filter.text));
                break;
            case CompareOperators.EndsWith:
                subset = subset.filter(row => row[filterableColumn.name].toLowerCase().endsWith(filterableColumn.filter.text));