SpagoBI data set: use javascript to access to MongoDB data base - javascript

Since data set in SpagoBI could be created using scripts, I need to connect, query my MongoDB data base using javascript (or Groovy).
I need to use scripts to be able to execute aggregation on the mongoDB data, I can't use aggregation directly on my MongoDB because my data type is String
I dont know how to access my Database using scripts
Any ideas?

You should create a Mongo dataset. The steps to create are:
Step1: Create a Mongo datasource in the administrator console. Notes: the type must be JDBC and the value for Class input field must be "mongo"
JDBC: {unit_host}:{port}/${db}
CLASS: mongo
Step2: now you can create a dataset. The procedure is the same of the query datasets. The difference here is the language.. JS instead of SQL.
Take a look at the SpagoBI wiki in particolar here: http://wiki.spagobi.org/xwiki/bin/view/spagobi_server/data_set#HQueryDataSet28Mongo29

When connecting to mongoDB, you pass auth stuff in the url. Since the scripts lies on the client side, it would be hard to make the connection secure (unless you are talking about backend JavaScript). Anybody would be able to see how to connect to your DB and for instance delete all content.
I would suggest a simple api to interface the database. Then u control the access to what a user can do towards the database.
Or have I misunderstood the scenario?

Related

Is there a text file containing my MongoDB data?

I have been using MongoDB atlas for a while now, and have decided to start hosting the database locally. After creating a new collection, completing all the standard steps, with no errors, and adding a new object with mongoose, I don't see the collection in my data/db file. Is there a different place where I should be looking to find plain text, as such in Atlas?
Like many databases, MongoDB does not store data in plain text files. It does use files but these files are binary and generally not usable directly by users.
Atlas does not provide filesystem access in any event, so whatever files it does use you won't be able to retrieve.
To extract your data, use a tool like mongodump.
Have a look at this page from the MongoDB docs.
It shows how to export the data as json or csv from Atlas
You can take the mongodump of your data from the atlas cluster and later on you can mongorestore it to your local deployment.
mongodump : https://docs.mongodb.com/manual/reference/program/mongodump/#bin.mongodump
mongorestore : https://docs.mongodb.com/manual/reference/program/mongorestore/#bin.mongorestore

MEAN: Doing database queries in Angular Frontend?

I was wondering if it is somehow possible to do MongoDB No-SQL Queries (or even SQL-queries for sql database) in the Angular frontend, like formulating the query and then sending the query string to the database and getting a subset of values back (e.g. in JSON-format).
Because the problem that I currently have is, that for each data snippet that I need, I have to create a specific route (e.g for one specific graph) and then do my middleware-function for that route that queries for the data in mongodb (e.g by mongodb aggregation framework). And then finally, do a http-request in Angular frontend, eventuelly format the data in javascript in angular and then insert the data in correct format into the appropriate charting-framework (e.g ngx-charts).
E.g. If I would like to filter the data in some chart for specific fields, or do some aggregation etc. on the same chart dynamically, I probably would just query all data from beginning, and then create my own (e.g. filter or other data manipulation) functions in javascript for my chart functions.
I heard there are some ways to do this also in the backend, e.g in Node or MongoDB Aggregation framework, there exists $facet operator that can choose some path for data operation, but I actually don't know how this works together with the Frontend...
Is there not a more direct way to query just the data that I need for a specific component without setting up routing and everything else around?

meteor dictionary on server with client (session) ids as key

When a client logs in, i want to store inside a dictionary the ids of the clients / sessions as keys inside a dictionary mapped to some data (In case there is no need for a dictionary and meteor has a way to map a single variable with client specific data it would be even better).
I am not familiar with developing Meteor packages and Javascript at all, so my question is: Where do i put this dictionary so i can access it from everywhere on the server and where can i get the clients ids?
Wished behaviour:
1. Client logs in -> Server registers new client id
2. Client calls function on server
3. Inside the function the server gets the right data according to the clients id for further processing
Inside a package (https://github.com/steffow/meteor-accounts-saml) i set up a global variable but when i tried to access it from javascript, inside the imports/api directory, the global variable was undefined.
You could use the Presences package to store information about each logged in user, https://github.com/dburles/meteor-presence. It automatically creates unique ids for these.
These database records are available both in the client and server. You can either fork and extend this package to store more information, or create another database table to store your information.

Query MongoDb with Java and pass it to d3/javascript?

I want to create a chart where I can select a time period and query mongodb accordingly. I want to use Java to query MongoDb. I know how to connect MongoDb and Java but I'm not so clear about linking the java to my webpage(i.e. To pass the data from that java file to my webpage/javascript).
I know Ajax calls can be used to link to servlets, but I'm sort of lost. Please help.
You use the Java MongoDB driver to connect to and query MongoDB from within your Java application. https://docs.mongodb.org/getting-started/java/client/
You would make that data available to the browser (D3/JavaScript) the same way you would make any server-side data available to the browser. You could either add that data to the page as you are rendering the actual webpage, or you could return the data in response to an AJAX request.

JSON data querying by breeze

I attempting my first SPA.
It will be a HTML representation of the model of our database structure to give to clients to look through the model and do queries of the database model (not the database data itself).
The requirement is then for no updates and the SPA will be shipped with the release and thus will be offline. Currently it is a static HTML page.
My question is - is there a way to use breeze to query the json file I've created that describes the model? All I've seen are examples of the EntityManager being initialised with a service URL - that will return the data.
Not quite sure I understand the question. What do you mean by (no server)?. Does this mean that you want to bring all of the data down just once and then query it locally?
If the data that you want to query is actually itself metadata then if you describe the structure of the metadata (i.e. metadata of metadata) in Breeze's native metadata format, then you should be able to query the metadata itself via Breeze's EntityQuery.
Probably a little more info would be helpful.
Also, take a look at the Breeze NoDb sample for an example of "custom" metadata construction.

Categories

Resources