Skip to content

Commit

Permalink
wip: Provide a messages service #908
Browse files Browse the repository at this point in the history
  • Loading branch information
cnouguier committed Aug 26, 2024
1 parent 2011fdc commit 65772ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions core/api/models/messages.model.mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ export default function (app, options) {
// Collation provided in query ensure sorting to be case insensitive w.r.t. user's language
// We built indices with collation to cover the most used languages, it requires different naming...
options.Model.createIndex({ createdAt: -1 })
options.Model.createIndex({ title: 1 }, { name: 'title-en', collation: { locale: 'en', strength: 1 } })
options.Model.createIndex({ title: 1 }, { name: 'title-fr', collation: { locale: 'fr', strength: 1 } })
options.Model.createIndex({ body: 1 }, { name: 'body-en', collation: { locale: 'en', strength: 1 } })
options.Model.createIndex({ body: 1 }, { name: 'body-fr', collation: { locale: 'fr', strength: 1 } })
options.Model.createIndex({ author: 1 }, { name: 'author-en', collation: { locale: 'en', strength: 1 } })
options.Model.createIndex({ author: 1 }, { name: 'author-fr', collation: { locale: 'fr', strength: 1 } })
}
7 changes: 6 additions & 1 deletion core/api/services/messages/messages.hooks.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import fuzzySearch from 'feathers-mongodb-fuzzy-search'
import commonHooks from 'feathers-hooks-common'
import { diacriticSearch } from '../../hooks/index.js'

export default {
before: {
all: [],
find: [],
find: [
fuzzySearch({ fields: ['title', 'body', 'author'] }),
diacriticSearch()
],
get: [],
create: [commonHooks.setNow('createdAt')],
update: [],
Expand Down

0 comments on commit 65772ad

Please sign in to comment.