autocomplete for attribute values, closes #31

This commit is contained in:
azivner
2018-02-04 19:43:11 -05:00
parent a3b31fab54
commit 52817504d1
3 changed files with 55 additions and 17 deletions

View File

@@ -47,8 +47,6 @@ router.put('/notes/:noteId/attributes', auth.checkApiAuth, wrap(async (req, res,
}));
router.get('/attributes/names', auth.checkApiAuth, wrap(async (req, res, next) => {
const noteId = req.params.noteId;
const names = await sql.getColumn("SELECT DISTINCT name FROM attributes");
for (const attr of attributes.BUILTIN_ATTRIBUTES) {
@@ -62,4 +60,12 @@ router.get('/attributes/names', auth.checkApiAuth, wrap(async (req, res, next) =
res.send(names);
}));
router.get('/attributes/values/:attributeName', auth.checkApiAuth, wrap(async (req, res, next) => {
const attributeName = req.params.attributeName;
const values = await sql.getColumn("SELECT DISTINCT value FROM attributes WHERE name = ? ORDER BY value", [attributeName]);
res.send(values);
}));
module.exports = router;