Initial code for Slack based search

This commit is contained in:
Jori Lallo
2016-08-22 23:37:01 -07:00
parent 70e46a5c05
commit 4f998bccc8
10 changed files with 131 additions and 37 deletions

View File

@ -78,25 +78,7 @@ router.post('documents.search', auth(), async (ctx) => {
const user = await ctx.state.user;
const sql = `
SELECT * FROM documents
WHERE "searchVector" @@ plainto_tsquery('english', :query) AND
"teamId" = '${user.teamId}'::uuid AND
"deletedAt" IS NULL
ORDER BY ts_rank(documents."searchVector", plainto_tsquery('english', :query))
DESC;
`;
const documents = await sequelize
.query(
sql,
{
replacements: {
query,
},
model: Document,
}
);
const documents = await Document.searchForUser(user, query);
const data = [];
await Promise.all(documents.map(async (document) => {