Class List Does Not Update
I built a node.js/Express API with OrientJS to query my OrientDB database. I use getClassList() [shown below] to retrieve a refreshed class list from the database to send back to the client in response to requests to refresh the class list, and add a new class or delete an existing class from the database. The function works well when refreshing a class list and when adding a new class, delivering an array of current classes to include the newly added class. However, when I submit a request to delete a class via the below express function, the response still includes the deleted class, and subsequent refresh attempts also provide a response with the deleted class. Oddly, if I restart the express server, the deleted class is gone from subsequent responses to request a refresh of the classes. I am at a loss to explain why the deleted class is not removed, and wondering if there is a cache setting in OrientJS that I am missing. I appreciate any insights.
function getClassList() {
return db.class.list()
.then(function(classes) {
classes.map(function(x) {
delete x.db;
if (x.properties.length > 0) {
x.properties.map(function(y) {
if (typeof(y.class) !== "undefined") {
y.className = y.class.name;
delete y.class;
}
});
}
});
return classes;
})
.then((classes) => classes);
}
app.delete("/class/:classname", function(req, res) {
db.query("DROP CLASS " + req.params.classname)
.then(() => getClassList())
.then((data) => res.json(data));
});
Hi @mpduffey
OrientJS caches the schema, that's why probably you still see the deleted class. You can pass the setting in order to refresh the cache.
return db.class.list(true) // true for refresh
Let me know if this helps