Giter Site home page Giter Site logo

Comments (5)

knadh avatar knadh commented on September 26, 2024

Hey, sorry for the delayed reply. Let me look into it implementing a sort method.

from localstoragedb.

juarezpaf avatar juarezpaf commented on September 26, 2024

It will be great for sure! πŸ˜„

from localstoragedb.

a904guy avatar a904guy commented on September 26, 2024

I started implementation but quit as it no longer fit my needs. Feel free to pick it up. @ (https://github.com/a904guy/localStorageDB/blob/master/localstoragedb.js)

@line: 166

// sort records by field name (sort) returned from select
function sort(results,sort)
{
    var r = [], sortable, s = sort;
    for(var record in results)
    {
        record.sort(function(a,b)
            { 
                if (typeof a[s].localeCompare === 'function') return a[s].localeCompare(b[s]);
                return a[s] - b[s];
            }
        );
        r.push(record);
    }
    return r;
}

@line: 619:

    // select rows
    query: function(table_name, query, limit, start, sort) {
        tableExistsWarn(table_name);

        var result_ids = [];
        if(!query) {
            result_ids = getIDs(table_name, limit, start); // no conditions given, return all records
        } else if(typeof query == 'object') {           // the query has key-value pairs provided
            result_ids = queryByValues(table_name, validFields(table_name, query), limit, start);
        } else if(typeof query == 'function') {     // the query has a conditional map function provided
            result_ids = queryByFunction(table_name, query, limit, start);
        }
        return sort(select(table_name, result_ids, limit),sort);
    },

from localstoragedb.

orangecoding avatar orangecoding commented on September 26, 2024

@a904guy see my PullReq. #35

from localstoragedb.

knadh avatar knadh commented on September 26, 2024

@juarezpaf, sorry it's been so long, but the multi-field sorting is now supported (63a1749). Thanks to @orangecoding.

from localstoragedb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.