Uh oh!
There was an error while loading. Please reload this page.
feature(collection): Add Collection.extendDomain() - #593
Closed
andreialecu wants to merge 1 commit into
Closed
Conversation
Static function that allows adding values or functions to the domains of all collection instances. Replaces deployd#315
andreialecu
commented
Jun 29, 2015
ContributorAuthor
You have access to Usage example: app.js varCollection=require('deployd/lib/resources/collection');vardeployd=require('deployd');Collection.extendDomain("getColName",function(){returnthis.collection.name;});Collection.extendDomain("hasChanges",function(){vardomain=this.domain;if(_.find(_.keys(domain.data),function(key){returndomain.changed(key);})){returntrue;}returnfalse;});// configure database etc.varserver=deployd({port: process.env.PORT||1337,env: process.env.ENV||'development',db: {connectionString: process.env.MONGO_URI}});// start the serverserver.listen();// debugserver.on('listening',function(){console.log("Server is listening on port: "+(process.env.PORT||1337));});// Deployd requires thisserver.on('error',function(err){console.error(err);process.nextTick(function(){// Give the server a chance to return an errorprocess.exit();});});You can then use those defined functions in your event scripts, example: On POST emit(getColName()+":post",this); |
ericfong
commented
Jun 30, 2015
Contributor
WOW. Great Feature!!! |
andreialecu
commented
Jun 30, 2015
ContributorAuthor
ericfong
commented
Jul 2, 2015
Contributor
Thanks for your contribution! |
andreialecu added a commit
to andreialecu/deployd
that referenced
this pull request
Jul 10, 2015
PR deployd#593 Collection.ExtendDomain wouldn't work with Collection.AfterCommit and UserCollection.Login events. Fixed it for consistency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Static function that allows adding values or functions to the domains of all collection instances.
Replaces #315