GithubHelp home page GithubHelp logo

lguzzon-scratchbook / angular-phonecat-mongodb-rest Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dalcib/angular-phonecat-mongodb-rest

0.0 1.0 0.0 5.73 MB

Example of Angular app with Node server and MongoDb Restful API

CSS 3.51% HTML 4.83% JavaScript 86.72% Batchfile 1.66% Shell 2.90% Ruby 0.39%

angular-phonecat-mongodb-rest's Introduction

Angular-PhoneCat-MongoDB-Rest

Angular 1.0.5 Version - http://angularjs.org

Overview

The goal of this project is to build Node server to Angular with a Restful complete API to mongoDB. This application is based in angular-phonecat - https://github.com/angular/angular-phonecat .

Install

To load de Phones to Mongo Database called "PhoneCat":

$ node load

To run the aplication:

$ node server

Rest API - Node/MongoDB/Angular

The Actions .get, .save, .delete and .query are default in Angular, and can be used like this way:

Resource.action({params}, [{postData}])

To more information look http://docs.angularjs.org/#!/api/angular.service.$resource

Read

.get({_id: _id})

Insert/Update

.save({},$scope.doc}

If the document don't have an "_id", the document is inserted and "_id" is created by ObjectId. If the document have a "_id" but this "_id" don't exist in the database, the document is inserted and a custon "_id" is created. Otherwise, the document is updated.

Delete

.delete({ _id: _id }
.query({})

.query({name : "same name", limit:10, skip:15, 
        sort:"age", order:"asc" || "desc"}}
.find({}, {'age': {'$lt":5, '$gt':3}})
.count()

.distinct({}, { key: "key" } Ex: {key: "carrier"})

.group({}, {keys: {carrier:true }, 
            cond: {}, 
            initial: {sum: 0, count:0, max:0, avg:0}, 
            reduce: "function(doc,out){ \\
                out.sum += doc.age; \\
                out.count += 1; \\
                out.max = Math.max(out.max, doc.age); \\
                out.avg = out.sum/out.count;}"
            }
.mapReduce({}, {map : mapfunction string, 
                reduce : reducefunction string,
                options: { 
                    query : query filter object, 
                    sort : sorts the input objects using this key
                    limit : number of objects to return from collection, 
                    finalize : finalizefunction,
                    scope : object where fields go into global scope 
                }}
       
                
Ex .mapReduce({},{"map": "function(){emit(this.details.android.os, 1);}", 
                "reduce": "function(key, values){return values.length;}"
                }

Alternative Sintax API

Angular-resource:  Phone.query({})
MondoDB: db.phones.query({})

Dependencies

  • Express
  • Mongojs

TODO

  • Tests

angular-phonecat-mongodb-rest's People

Contributors

dalcib avatar lguzzon avatar

Watchers

 avatar

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.