Coder Social home page Coder Social logo

breeze.sugar's Introduction

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');

breeze.sugar's People

Contributors

safrazik avatar

Stargazers

 avatar

Watchers

 avatar

breeze.sugar's Issues

Add support for multiple operators for a property

In mongodb, it is possible to add multiple conditions for a particular property in one object representation

price: {$gt: 50, $lt: 100}

Workaround for now is to use the alternative syntax of mongodb

$and: [{price: {$gt: 50}}, {price: {$lt: 100}}]

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.