Skip to content

safrazik/breeze.sugar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Project Status: 🚨 Unmaintained 🚨

This project is no longer maintained. We will not be accepting pull requests, addressing issues, nor making future releases.

breeze.sugar

Syntax sugar (Mongo DB style queries) for breeze js

API

createQuery(resourceName [, criteria [, options ]])

Create an EntityQuery in mongodb style

Arguments

  • resourceName String entityType's resource name to query from
  • criteria Object Mongodb style query criteria
  • options Object
    • sort Object Sort order
    • skip Number Number of results to skip at the beginning
    • limit Number Maximum number of results to return
    • expand Object The navigation properties to expand

Returns

breeze.EntityQuery

Usage

var query = sugar.createQuery('Customers', 
   {  // criteria
      'country.code': 'en-US',
      $or: [
        {age: {$gt: 18}},
        {name: {$contains: 'z'}}
      ],
    },
    { // options
      limit: 10,
      skip: 5,
      sort: {
         name: -1
      },
      expand: {
         country: true
      }
   });

the above code is converted into:

var query = new breeze.EntityQuery().from('Customers').where(
  breeze.Predicate.and(
    new breeze.Predicate('country.code', '==', 'en-US'),
    breeze.Predicate.or(
      new breeze.Predicate('age', 'gt', 18),
      new breeze.Predicate('name', 'contains', 'z')
    )
  )
)
.top(10)
.skip(5)
.orderBy('name desc')
.expand('country');

About

Syntax sugar (Mongo DB style queries) for breeze js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published