Created
July 10, 2011 18:39
-
-
Save billywhizz/1074820 to your computer and use it in GitHub Desktop.
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
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