(d, db)
return {name: added}
saves the given name:list of dicts to mongodb
    adds entry to db if it isnt already there
saves the given name:list of dicts to mongodb
    adds entry to db if it isnt already there
saves the given name : list of dicts to mongodb adds entry to db if it isnt already there
def save(d, db):
    '''
    saves the given name:list of dicts to mongodb
    adds entry to db if it isnt already there
    '''
    name = list(d.keys())[0]
    collection = db[name]
    added = []
    for item in d[name]:
        if collection.find_one({'title': item['title']}) is None:
            collection.update({'title': item['title']}, item, upsert=True)
            added.append(item)
    logging.debug('Finished saving {} items to {} collection'.format(len(added), name))
    return {name: added}
def save ( d , db ) : name = list ( d . keys ( ) ) [ 0 ] collection = db [ name ] added = [ ] for item in d [ name ] : if collection . find_one ( { 'title' : item [ 'title' ] } ) is None : collection . update ( { 'title' : item [ 'title' ] } , item , upsert = True ) added . append ( item ) logging . debug ( 'Finished saving {} items to {} collection' . format ( len ( added ) , name ) ) return { name : added }