Added data indexing & indexed queries, improved locking mechanism, added tests, fixed bugs, much more

This commit is contained in:
Ewout Stortenbeker 2018-08-02 11:20:34 +02:00
parent 0fb2598d80
commit eee7dfc363

View file

@ -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: [],