Make native query in standalone Waterline - express

When trying to use Waterline standalone mode, I could not find the correct method to perform native queries. With Sails.JS the sendNativeQuery method is used which I could not find in the instances of the models. Does anyone know how I can perform these queries?
Thank you!
I have the same problem, i think it sail who set getDatastore() and sendNativeQuery() function on model and datastore.
Surely on this file: https://github.com/balderdashy/sails-hook-orm/blob/master/lib/build-registered-datastore-instance.js
and the function is defined here: https://github.com/balderdashy/sails-hook-orm/blob/master/lib/build-registered-datastore-instance.js
Im going to implement this in my code but if someone have a better idea or have already doing this i appreciate help :)

Sails enables you to access what called datastore.manager
Depending on the adapter, this might represent a connection pool, a single connection, or even just a reference to a pre-configured client library instance.
If you are using MongoDB for example, you can have a raw Mongo collection instance.
see here.

Related

Add dynamic resource with PUT on non-existent path with Californium

I want the Californium CoAP server to handle a PUT request with a yet non-existent Resource path. Instead of providing an Error return message, the server should dynamically add a resource with the path the PUT method is targeting.
I am using the cf-plugtest-server coming with the Californium Core library in Java to try to implement this function. Unfortunately i am completely new to Californium and couldn't find a solution approach.
So far i found out the "resource not found" output is taking place at the ServerMessageDeliverer in californium.core.server with deliverRequest. However i don't know how to proceed from here.
Any help is very much appreciated. I am sorry if a solution to this is more obvious, i am fairly new to such a kind of programming. Thank you in advance!
Manipulations/changes on the resource tree are currently not supported out of the box.
The currently intended way is to provide a specific implementation of ServerMessageDeliverer which overrides the preDeliverRequest. there you may create the resource you want and add it to the resources tree.

How can I build an Agroal connection at runtime with native support

I'm trying to build a dynamic database connection via Agroal inside a native image. It's not possible to use the default config params because I don't know the connection params at compile time. Is that even possible right now?
The connection is built like this at runtime:
AgroalDataSource.from(
AgroalDataSourceConfigurationSupplier()
...)
I'm currently seeing this error:
Class io.agroal.pool.ConnectionHandler[] is instantiated reflectively but was never registered.
Register the class by using org.graalvm.nativeimage.hosted.RuntimeReflection
The installed features include: [agroal, cdi, jdbc-h2, jdbc-mysql, jdbc-postgresql, kotlin, narayana-jta, resteasy, resteasy-jackson]
It runs fine on the JVM, but not using Graal. It feels like it should be possible and I'm probably missing something here. I was hoping adding agraol extension would be sufficient but obviously isn't picked up correctly.
The current situation is that we configure Agroal for native images only if you have a datasource defined using Quarkus configuration.
Thus for your use case, for now, you will have to do what we do automatically manually. What we do being registering some classes for reflection and including some resources in the native image.
See https://github.com/quarkusio/quarkus/blob/master/extensions/agroal/deployment/src/main/java/io/quarkus/agroal/deployment/AgroalProcessor.java#L91 and https://quarkus.io/guides/writing-native-applications-tips#using-a-configuration-file.
Obviously, that's not ideal. Could you open an issue on our GitHub so that we can discuss it internally and see if we should/can improve the situation?
In the end, you would still need some reflection registration for your JDBC driver though.

Express-browserify and Watson Visual Recognition - TypeError: fs.existsSync is not a function

I'm trying to get the Watson Visual Recognition to run client side by using express-browserify with reference to the node-sdk for watson-developer-cloud. The VisualRecognitionV3 makes use of the fs package hence I get the fs.existsSync error when I'm trying to call it from the client-side as the browser doesn't know which filesystem to use. My question is how do I go about creating a so called 'abstraction layer' as I am restricted to using the express-browserify package for cross origin calls.
This thread is pretty helpful in shedding some light but I'm not sure where to start regarding the 'abstraction layer' or if there are any other solutions. Also, would something like socket.io work for this? I've linked a clone of the directory here as it seems less clunky than pasting the multiple portions below.
The repository can be cloned and just requires a personal iam_apikey with relevant launch configuration. Appreciate any pointers. Thanks!
I didn't manage to sort this out with express-browserify due to the require(fs) from browser issue but I was able to get it running using the express-ws package

How to consume a graphql API with Vue

Pretty simple you'd think given the popularity of both, but I am encountering a few hurdles.
I am using scaphold.io to be able to quickly show off a working UI. That is, if Vue can interact with Scaphold.
I have investigated two resources:
https://github.com/kristianmandrup/vue2-apollo-scaphold
Which seems to be a Scaphold production. Tried it. Many, many vague bugs.
Then there is also:
https://github.com/Akryum/vue-apollo
But this is too much. I don't need a server, the server is on Scaphold.
I also tried building the whole thing up by using the tutorial on howtographql, but this one is also outdated.
Ideally I want to instantiate an as up to date Vue 2 app using (I guess) the npm vue-cli, then install only the required apollo (or whatever, but I guess apollo) add-ons that I need. The minimum.
Shouldn't be too hard, I'll figure it out eventually, but some help is more than welcome.
You can consume a graphql api using your favorite regular request module (ajax, fetch, axios). Take the scalphold docs for example, but in the callback do this.vueUserData = body.data.getUser;
instead of
console.log(JSON.stringify(body, null, 2));
(edited to add one gotcha I remembered: if you encounter a problem where the callback doesn't know that this is supposed to be the component, you can do var self = this before the request function, then reference self.vueUserData instead.)

Using Raw Queries in a Sails App using Sequelize as ORM

I am working with a sails application that uses Sequelize as the ORM tool. Initial integration between the app and Sequelize was established via the sails-hook-sequelize plugin which can be found here. This approach has worked great so far, no problem defining and using models.
However, I hit a road block when I wanted to define a View as a Sequelize object. Sequelize doesn't (yet) have an easy way to do this. The work around I found was to execute a raw query and populate a table with the result.
Now I come to the second road block and the actual question itself. How do I simply execute a sequelize.query inside of my sails application? In stand alone node apps using sequelize I don't have a problem. However, this sails application has gotten away from me to the point where I'm not sure what object to actually call .query from! What I'm looking for is something simple like
Sequelize.query("SELECT * FROM `Document.MyView`", { type: Sequelize.QueryTypes.SELECT})
Sadly the above gives me sequelize.query is not a function
I have a connections.coffee file where the database connection is defined. It is named 'Core', however when I try Core.query I get Core is undefined
Seems like I am missing something simple and fundamental from stacking too many things on top of the other.
Alright my problems arose from the sails-hook-sequelize plugin. Luckily my answer came from that plugin as well!
"sequelize" is a global in this plugin. So don't add a sequelize = require 'sequelize'.
simply call the raw query with sequelize.query as expected (case sensitive).
Then your raw query should work! Thanks from past me.