<commit_before>
module.exports = function(req, res, next) {
    var data = req.body;
    return models.favorite.createAsync({
        location: {
            id: data.id,
            name: data.name,
            category: data.category,
            latitude: data.latitude,
            longitude: data.longitude,
            checkins: data.checkins,
            checkins_upcount: data.checkins_upcount,
            startdate: data.startdate
        },
        createdBy: data.userId
    })
    .then(function(favorite) {
        return res.api(favorite);<commit_msg>favorite create finish<commit_after>
module.exports = function(req, res, next) {
    var data = req.body;

    Promise.map(data.locations, function(location){

        return models.favorite.findOne()
            .where('location.id').equals(location.id)
            .where('trashed').equals(false)
            .where('createdBy').equals(data.userId)
            .execAsync()
            .then(function(doc) {

                if(doc){
                    return Promise.resolve(doc);
                }

                return models.favorite.createAsync({
                    location: location,
                    createdBy: data.userId
                });
            });
    })
    .then(function(favorites) {
        return res.api(favorites);
{'fraction_non_alphanumeric': 0.11330798479087452, 'fraction_numerical': 0.0, 'mean_word_length': 1.6747967479674797, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2860936', 'n_tokens_mistral': 365, 'n_tokens_neox': 355, 'n_words': 62}