mirror of
https://github.com/appy-one/acebase-server.git
synced 2026-06-30 06:02:05 -06:00
Added data indexing & indexed queries, improved locking mechanism, added tests, fixed bugs, much more
This commit is contained in:
parent
0fb2598d80
commit
eee7dfc363
1 changed files with 26 additions and 2 deletions
|
|
@ -182,8 +182,8 @@ class AceBaseServer extends EventEmitter {
|
|||
// Execute query
|
||||
const path = req.path.substr(dbname.length + 8);
|
||||
const data = transport.deserialize(req.body);
|
||||
const ref = db.ref(path);
|
||||
const query = ref.query();
|
||||
//const ref = db.ref(path);
|
||||
const query = db.query(path);
|
||||
data.query.filters.forEach(filter => {
|
||||
query.where(filter.key, filter.op, filter.compare);
|
||||
});
|
||||
|
|
@ -213,6 +213,30 @@ class AceBaseServer extends EventEmitter {
|
|||
});
|
||||
});
|
||||
|
||||
app.get(`/index/${dbname}`, (req, res) => {
|
||||
// Get all indexes
|
||||
db.indexes.list()
|
||||
.then(indexes => {
|
||||
res.send(indexes);
|
||||
});
|
||||
});
|
||||
|
||||
app.post(`/index/${dbname}`, (req, res) => {
|
||||
// create index
|
||||
const data = req.body;
|
||||
if (data.action === "create") {
|
||||
db.indexes.create(data.path, data.key)
|
||||
.then(() => {
|
||||
res.send({ success: true });
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
res.statusCode = 500;
|
||||
res.send(err);
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
// Websocket implementation:
|
||||
const clients = {
|
||||
list: [],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue