DoneJS StealJS jQuery++ FuncUnit DocumentJS
5.33.3
6.0.0 4.3.0 3.14.1 2.3.35
  • About
  • Guides
  • API Docs
  • Community
  • Contributing
  • Bitovi
    • Bitovi.com
    • Blog
    • Design
    • Development
    • Training
    • Open Source
    • About
    • Contact Us
  • About
  • Guides
  • API Docs
    • Observables
      • can-bind
      • can-compute
      • can-debug
      • can-define
      • can-define/list/list
      • can-define/map/map
      • can-define-backup
      • can-define-stream
      • can-define-stream-kefir
      • can-event-queue
      • can-kefir
      • can-list
      • can-map
      • can-map-compat
      • can-map-define
      • can-observable-array
      • can-observable-object
      • can-observation
      • can-observation-recorder
      • can-observe
      • can-simple-map
      • can-simple-observable
      • can-stream
      • can-stream-kefir
      • can-value
    • Views
      • can-attribute-observable
      • can-component
      • can-stache
      • can-stache-bindings
      • can-stache-converters
      • can-stache-element
      • can-stache-route-helpers
      • can-view-autorender
      • can-view-callbacks
      • can-view-import
      • can-view-live
      • can-view-model
      • can-view-nodelist
      • can-view-parser
      • can-view-scope
      • can-view-target
      • steal-stache
    • Data Modeling
      • can-connect
      • can-connect-feathers
      • can-connect-ndjson
      • can-connect-tag
      • can-fixture
      • can-fixture-socket
      • can-local-store
      • can-memory-store
      • can-ndjson-stream
      • can-query-logic
        • prototype
          • count
          • difference
          • filterMembers
          • filterMembersAndGetCount
          • identityKeys
          • index
          • intersection
          • isDefinedAndHasMembers
          • isEqual
          • isMember
          • isProperSubset
          • isSpecial
          • isSubset
          • union
          • unionMembers
        • query format
          • Query
          • Comparison Operators
        • static methods
          • defineComparison
          • set.difference
          • set.intersection
          • set.union
        • static types
          • EMPTY
          • KeysAnd
          • UNDEFINABLE
          • UNIVERSAL
          • UNKNOWABLE
          • makeEnum
      • can-realtime-rest-model
      • can-rest-model
      • can-set-legacy
      • can-super-model
    • Routing
      • can-deparam
      • can-param
      • can-route
      • can-route-hash
      • can-route-mock
      • can-route-pushstate
    • JS Utilities
      • can-assign
      • can-define-lazy-value
      • can-diff
      • can-globals
      • can-join-uris
      • can-key
      • can-key-tree
      • can-make-map
      • can-parse-uri
      • can-queues
      • can-string
      • can-string-to-any
      • can-zone-storage
    • DOM Utilities
      • can-ajax
      • can-attribute-encoder
      • can-child-nodes
      • can-control
      • can-dom-data
      • can-dom-events
      • can-dom-mutate
      • can-event-dom-enter
      • can-event-dom-radiochange
      • can-fragment
    • Data Validation
      • can-define-validate-validatejs
      • can-type
      • can-validate
      • can-validate-interface
      • can-validate-legacy
      • can-validate-validatejs
    • Typed Data
      • can-cid
      • can-construct
      • can-construct-super
      • can-data-types
      • can-namespace
      • can-reflect
      • can-reflect-dependencies
      • can-reflect-promise
      • can-types
    • Polyfills
      • can-symbol
      • can-vdom
    • Core
    • Infrastructure
      • can-global
      • can-test-helpers
    • Ecosystem
    • Legacy
  • Community
  • Contributing
  • GitHub
  • Twitter
  • Chat
  • Forum
  • News
Bitovi

Query

  • Edit on GitHub

The default structure of objects used to represent queries.

{filter: FILTER, sort: SORT, page: PAGE}

The following is an example query:

{
    // Selects only the todos that match.
    filter: {
        complete: false
    },
    // Sort the results of the selection
    sort: "name desc",
    // Selects a range of the sorted result
    page: {start: 0, end: 19}
}

Parameters

  1. filter {Object}:

    The filter property is an object of property names to values like:

    {
        filter: {
            age: {$gt: 21},
            name: ["Justin","Ramiya"]
        }
    }
    

    The Comparison Operators ($eq, $gt, $gte, $in, $lt, $lte, $ne, $nin) are available within filter.

  2. sort {String}:

    The sort property is an optional value specifying:

    • the property used to sort the results of a query, and
    • the direction of the sort (start the value with - for descending).

    The sort property is specified as a string like sort: "age". sort: "age" will return results ascending by the age property. sort: "-age" will return results descending by the age property.

    This format follows JSON API's recommendations on sorting. However, can-query-logic can only sort by a single property currently.

    The sort property defaults to "ID_PROPERTY" where ID_PROPERTY is the first identity property returned by identityKeys. This is usually the first identity value on the schema passed to new QueryLogic():

    new QueryLogic({
        identity: ["_id"]
    }).identityKeys() //-> ["_id"]
    
  3. page {Object}:

    The optional page property selects a range of the sorted result. It's values are inclusive and begin at 0. This means that:

    • {start: 0, end: 1} - Selects the first two records in the result.
    • {start: 10, end: 19} - Selects 10 records after the first 10 records.

    The start value defaults to 0 and the end value defaults to Infinity. This means that:

    • {end: 99} - Selects the first 100 records.
    • {start: 100} - Selects all records after the first 100.

CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 5.33.3.

On this page

Get help

  • Chat with us
  • File an issue
  • Ask questions
  • Read latest news