Skip to content

Instantly share code, notes, and snippets.

@ralt
Forked from Raynos/x.js
Created May 29, 2012 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralt/2829618 to your computer and use it in GitHub Desktop.
Save ralt/2829618 to your computer and use it in GitHub Desktop.
var UserCollection = require("../dataSources/user")
var User = {
find: function( name, skypeName, callback ) {
if ( skypeName ) {
findBySkypeName( name, callback );
}
// The rest of your logic there
}
}
function findBySkypeName( name, callback ) {
UserCollection.getBySkypeName( name, function( err, user ) {
if ( !user ) {
return UserCollection.createFromSkypeName(name, callback);
}
return callback( null, user );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment