mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
Handled our forced null conversion in bookshelf
refs https://github.com/TryGhost/Arch/issues/47 We've configured bookshelf to force empty strings to null, but this is undesired behaviour here, so unfortunately we have to leak some business logic into the repository. This needs to be done to correctly support our filter validation logic.
This commit is contained in:
parent
359617462a
commit
27bfa30f97
@ -66,13 +66,17 @@ module.exports = class BookshelfCollectionsRepository {
|
||||
|
||||
#modelToCollection(model) {
|
||||
const json = model.toJSON();
|
||||
let filter = json.filter;
|
||||
|
||||
if (json.type === 'automatic' && typeof filter !== 'string') {
|
||||
filter = '';
|
||||
}
|
||||
return Collection.create({
|
||||
id: json.id,
|
||||
slug: json.slug,
|
||||
title: json.title,
|
||||
description: json.description,
|
||||
filter: json.filter,
|
||||
filter: filter,
|
||||
type: json.type,
|
||||
featureImage: json.feature_image,
|
||||
posts: json.collectionPosts.map(collectionPost => collectionPost.post_id),
|
||||
|
Loading…
Reference in New Issue
Block a user