Skip to content

Instantly share code, notes, and snippets.

@billywhizz
Created July 10, 2011 18:39
Show Gist options
  • Save billywhizz/1074820 to your computer and use it in GitHub Desktop.
Save billywhizz/1074820 to your computer and use it in GitHub Desktop.
function handleFailure(err) {
next(new DbError(err));
}
function findBlogCb(blog) {
var proj;
function setBlogCb() {
proj.setUsers(users).on("success", setUsersCb).on("failure", handleFailure);
}
function setUsersCb() {
// do stuff
}
function createProjectCb(project) {
proj = project;
project.setBlog(blog).on("success", setBlogCb).on("failure", handleFailure);
}
function findUsersCb(users) {
if (!users) return res.send({ errors: "Users do not exist."});
Project.create(req.form.project).on("success", createProjectCb).on("failure", handleFailure);
}
if (!blog) return res.send({ errors: "Blog does not exist."});
User.findAll(req.form.users).on("success", findUsersCb).on("failure", handleFailure);
}
Blog.find(req.form.blog).on("success", findBlogCb).on("failure", handleFailure);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment