2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00
Ghost/core/shared/nql-map-key-values
Kevin Ansfield e57e19ec31
🏗 Migrated posts.page column to posts.type (#11111)
refs https://github.com/TryGhost/Ghost/issues/10922

- adds migrations to...
  1. add `post.type` column
  2. populate `post.type` column based on `post.page` value
  3. drop `post.page` column
- updates all code paths to work with `post.type` in place of `post.page`
- adds `nql-map-key-values` transformer for mapping `page`->`type` in `filter` params when using the v2 API
- modifies importer to handle `post.page`->`post.type` transformation when importing older export files
2019-09-16 11:51:54 +01:00
..
index.js 🏗 Migrated posts.page column to posts.type (#11111) 2019-09-16 11:51:54 +01:00
package.json 🏗 Migrated posts.page column to posts.type (#11111) 2019-09-16 11:51:54 +01:00
README.md 🏗 Migrated posts.page column to posts.type (#11111) 2019-09-16 11:51:54 +01:00

nql-map-key-values

This utility returns a transformer which can be passed to the @nexes/nql library to transform queries

Usage

const nql = require('@nexes/nql');
const mapKeyValues = require('nql-map-key-values');

nql('good:true', {
    transformer: mapKeyValues({
        key: {
            from: 'good',
            to: 'bad'
        },
        values: [{
            from: true,
            to: false
        }, {
            from: false,
            to: true
        }]
    });
}).toJSON(); // => {bad: false}