Skip to content

Commit

Permalink
fix: Impossible to update layer when base query contains an operator (c…
Browse files Browse the repository at this point in the history
…loses #907)
  • Loading branch information
claustres committed Jul 24, 2024
1 parent 2845b40 commit be349e1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions map/api/services/catalog/catalog.hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,22 @@ export default {
get: [],
create: [
coreHooks.checkUnique({ field: 'name', query: (query, hook) => { query.type = _.get(hook, 'data.type') } }),
coreHooks.convertObjectIDs(['baseQuery.layer']),
coreHooks.convertToString(['schema.content', 'filters']),
coreHooks.convertToString(['baseQuery', 'schema.content', 'filters']),
setNow('createdAt', 'updatedAt'),
// This allow to use keys for base queries like 'properties.xxx': 'yyy'
(hook) => { _.set(hook, 'params.mongodb.checkKeys', false) }
],
update: [
coreHooks.populatePreviousObject,
coreHooks.checkUnique({ field: 'name', query: (query, hook) => { query.type = _.get(hook, 'params.previousItem.type') } }),
coreHooks.convertObjectIDs(['baseQuery.layer']),
coreHooks.convertToString(['schema.content', 'filters']),
coreHooks.convertToString(['baseQuery', 'schema.content', 'filters']),
discard('createdAt', 'updatedAt'),
setNow('updatedAt')
],
patch: [
coreHooks.populatePreviousObject,
coreHooks.checkUnique({ field: 'name', query: (query, hook) => { query.type = _.get(hook, 'params.previousItem.type') } }),
coreHooks.convertObjectIDs(['baseQuery.layer']),
coreHooks.convertToString(['schema.content', 'filters']),
coreHooks.convertToString(['baseQuery', 'schema.content', 'filters']),
discard('createdAt', 'updatedAt'),
setNow('updatedAt')
],
Expand All @@ -44,7 +41,8 @@ export default {

after: {
all: [
coreHooks.convertToJson(['schema.content', 'filters'])
coreHooks.convertToJson(['baseQuery', 'schema.content', 'filters']),
coreHooks.convertObjectIDs(['baseQuery.layer'])
],
find: [
// Merge built-in categoriessublegends with user-defined ones for global catalog only
Expand Down

0 comments on commit be349e1

Please sign in to comment.