I have
Page.findById(pageId).then(page => {
const pageId = page.id;
..
});
My query is that if no page id is provided, it should just use the first available page provided some conditions, which is done by
Page.findOne({}).then(page => {
const pageId = page.id;
..
});
but if there is no page then it should create a new page and use this, which is done with
Page.create({}).then(page => {
const pageId = page.id;
..
});
But all I want is to merge all this to a few lines... Is it possible?