Skip to content

Commit

Permalink
Add rest api query to support selective sticky notes
Browse files Browse the repository at this point in the history
Part of #74
  • Loading branch information
nebulade committed Oct 14, 2017
1 parent 70e64a7 commit 8fd3d72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions frontend/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ ThingsApi.prototype.get = function (filter, isArchived, callback) {
if (filter) this._query.filter = filter;
if (isArchived) this._query.archived = true;

// TODO add ui to toggle this based on user preference
this._query.sticky = true;

this._query.skip = 0;
this._query.limit = 10;

Expand Down
11 changes: 7 additions & 4 deletions src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,22 @@ function profile(req, res, next) {
}

function getAll(req, res, next) {
// TODO make sticky selectable by the api to optionally not show sticky ones on search
var query = { $or: [ { sticky: true } ]};
var query = { $or: [] };

if (req.query && req.query.filter) {
if (req.query.filter) {
query.$or.push({
$text: { $search: String(req.query.filter) }
});
} else {
query.$or.push({ content: { $exists: true }});
}

if (req.query.sticky) {
query.$or.push({ sticky: true });
}

var archiveQuery;
if (req.query && req.query.archived) {
if (req.query.archived) {
archiveQuery = {
archived: true
};
Expand Down

0 comments on commit 8fd3d72

Please sign in to comment.