Skip to content

Instantly share code, notes, and snippets.

@ralt
Forked from Raynos/x.js
Created May 29, 2012 17:22
Show Gist options
  • 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