Renamed page->type in the page&posts serializers

refs #10922
This commit is contained in:
Fabien O'Carroll 2019-07-31 14:02:21 +08:00
parent fb8eadb4a8
commit df99e724e3
2 changed files with 46 additions and 0 deletions

View File

@ -3,6 +3,27 @@ const debug = require('ghost-ignition').debug('api:v2:utils:serializers:input:pa
const converters = require('../../../../../lib/mobiledoc/converters');
const url = require('./utils/url');
const localUtils = require('../../index');
const mongo = require('./utils/mongo');
/*
* Replaces references of "page" in filters
* with the correct column "type"
*/
function replacePageWithType(mongoJSON) {
return mongo.mapKeysAndValues(mongoJSON, {
key: {
from: 'page',
to: 'type'
},
values: [{
from: false,
to: 'post'
}, {
from: true,
to: 'page'
}]
});
}
function removeMobiledocFormat(frame) {
if (frame.options.formats && frame.options.formats.includes('mobiledoc')) {
@ -86,6 +107,8 @@ module.exports = {
defaultRelations(frame);
}
frame.options.mongoTransformer = replacePageWithType;
debug(frame.options);
},

View File

@ -4,6 +4,27 @@ const url = require('./utils/url');
const localUtils = require('../../index');
const labs = require('../../../../../services/labs');
const converters = require('../../../../../lib/mobiledoc/converters');
const mongo = require('./utils/mongo');
/*
* Replaces references of "page" in filters
* with the correct column "type"
*/
function replacePageWithType(mongoJSON) {
return mongo.mapKeysAndValues(mongoJSON, {
key: {
from: 'page',
to: 'type'
},
values: [{
from: false,
to: 'post'
}, {
from: true,
to: 'page'
}]
});
}
function removeMobiledocFormat(frame) {
if (frame.options.formats && frame.options.formats.includes('mobiledoc')) {
@ -108,6 +129,8 @@ module.exports = {
defaultRelations(frame);
}
frame.options.mongoTransformer = replacePageWithType;
debug(frame.options);
},