function createDraft(draft) {
    const creationDate = new Date().toJSON();
    const lastUpdatedDate = creationDate;
    const authorUid = draft.authorUid;
    const draftToSave = _.assign({}, _.pick(draft, draftProps), {writtenDate: lastUpdatedDate});

    const objectToSave = {
        published: false,
        creationDate,
        lastUpdatedDate,
        versions: [draftToSave],
        latestVersion : draftToSave,
        authorUid,
        version: 1
    };

    return new Promise((resolve, reject) => {
        drafts.push(objectToSave)
              .then(result => resolve(_.assign({},  {key: result.key}, objectToSave)))
              .catch(reject);
    });
}
/**
 *
 * @param draft - must contain these props: 'authorUid', 'title'
 *                can optionally contain 'content', 'thumbnailName', 'thumbnailUrl'
 *
 * @returns Promise which will resolve with newly saved draft object which contains
 *          it's firebase key as the value for 'key'
 */


@returns Promise which will resolve with newly saved draft object which contains
it's firebase key as the value for 'key'
@returns Promise which will resolve with newly saved draft object which contains it ' s firebase key as the value for ' key '
function createDraft(draft) {
    const creationDate = new Date().toJSON();
    const lastUpdatedDate = creationDate;
    const authorUid = draft.authorUid;
    const draftToSave = _.assign({}, _.pick(draft, draftProps), {writtenDate: lastUpdatedDate});
    const objectToSave = {
        published: false,
        creationDate,
        lastUpdatedDate,
        versions: [draftToSave],
        latestVersion : draftToSave,
        authorUid,
        version: 1
    };
    return new Promise((resolve, reject) => {
        drafts.push(objectToSave)
              .then(result => resolve(_.assign({},  {key: result.key}, objectToSave)))
              .catch(reject);
    });
}
function createDraft ( draft ) { const creationDate = new Date ( ) . toJSON ( ) ; const lastUpdatedDate = creationDate ; const authorUid = draft . authorUid ; const draftToSave = _ . assign ( { } , _ . pick ( draft , draftProps ) , { writtenDate : lastUpdatedDate } ) ; const objectToSave = { published : false , creationDate , lastUpdatedDate , versions : [ draftToSave ] , latestVersion : draftToSave , authorUid , version : 1 } ; return new Promise ( ( resolve , reject ) => { drafts . push ( objectToSave ) . then ( result => resolve ( _ . assign ( { } , { key : result . key } , objectToSave ) ) ) . catch ( reject ) ; } ) ; }
@param draft - must contain these props: 'authorUid', 'title'
                can optionally contain 'content', 'thumbnailName', 'thumbnailUrl'
@param draft - must contain these props : ' authorUid ' ' title ' can optionally contain ' content ' ' thumbnailName ' ' thumbnailUrl '