Skip to content

Instantly share code, notes, and snippets.

@sdepold
Created September 16, 2010 20:33
Show Gist options
  • Save sdepold/583112 to your computer and use it in GitHub Desktop.
Save sdepold/583112 to your computer and use it in GitHub Desktop.
var tags = tags_text.split(',');
var errors = [];
if (errors.length > 0) {
} else {
var new_question = new db.Question({
title: title,
body: body,
doNotify: doNotify,
doNotifyEmail: doNotifyEmail
});
var savings = [],
tagObjects = []
savings.push({save: new_question})
tags.forEach(function(_tag) {
var tag = new db.Tag({ tag: tag.trim() })
tagObjects.push(tag)
})
tagObjects.forEach(function(tag) {
savings.push({save: tag})
})
Sequelize.chainQueries(savings, function() {
new_question.setTags(tagObjects)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment