I'm trying to dynamically generate databases/collections on application startup, in case they do not exist yet. This works fine when working with the _system database. The thing is that it seems not to be allowed when trying to switch to other databases. From the docs:
db._useDatabase(name)
Changes the current database to the database specified by name. Note
that the database specified by name must already exist.
Changing the database might be disallowed in some contexts, for
example server-side actions (including Foxx).
Does this mean that Foxx applications can only create collections within the _system database? My manifest file sets the isSystem property to false. What is the meaning of such limitation?
A Foxx is included in one database context and has access to the collections there.
You can install Foxx apps in different databases.
f.E. you can run the following commands in arangosh to install the foxx app "example" in the database "myDB":
db._useDatabase("myDB")
fm.install("example","/example")
your app will than be reachable at (assuming standard configuration):
http://localhost:8529/_db/myDB/example
It is intentionally not possible to access a different database from within a Foxx app.
Related
I would like to know if it's possible to set the database in a connection at runtime (nestjs with TypeOrm and postgres). I'm having a system where there are many tenants and each one has it's own isolated database. The structure of the databases are all exactly the same and i want to use the same entity classes in my code.So after a user logs in, i want to set the database name to be used at runtime.
I cheked few solution working with : Connection, createConnection, getConnectionManager of'typeorm' , which are deprecated , i Wonder if this is possible with DataSource and how can i implement named connection with dataSource (equivalent of getConnection(tenant.name))
ps: i am using '#nestjs/passport' guards
Thanks.
So basically I have a SQLite3 Database that I am using for a Discord Bot. Is it possible for me to access my database file to check what's inside while the application is hosted and live?
I've considered that it is probably possible to do this from the command line within my terminal that I use to access the virtual host, but I do not know where to begin/what to input.
Ideally I would want to be able to view the file inside the DB Browser for SQLite program, for visual purposes, but for starters I want to know if its possible to see the live-updated database remotely, as my application is hosted on a virtual host/machine.
You can install phpliteadmin (https://www.phpliteadmin.org/) on your server to view your database.
Otherwise your can download your database file and view it in a client (Example of online client: https://extendsclass.com/sqlite-browser.html)
If one Nodejs app connects to a Mongo instance, and that app has defined a User schema with pre-save hooks, validation, etc.
And then another Nodejs app connects to the same database, and tries to register a User schema with different properties.
And then the second app saves a User
What happens?
I'm confused with how two Nodejs apps may communicate to the same database.
For example, it's very easy to see how one might want to have V2 of an api on a separate nodejs app developed by a separate team. But they will plug it into the same database and use the same Schema (or will they?), and I'm confused with how things are shared between the two apps.
Any help clarifying this in best-practices would be appreciated
I believe I've found the answer in the Documentation.
This connection object is then used to create and retrieve models. Models are always scoped to a single connection. docs
And
Models are fancy constructors compiled from our Schema definitions. docs
Which explains that a DB Connection 1's Schema Definitions (pre-save, etc), do not affect DB Connection 2's writes/etc.
Essentially, they are completely independent of validation and everything else. They only need to be OK in their own context.
I have a working Jhipster application, linked to a mysql database.
I would like to create a new application that I would connect to the first application database.
Is it possible? regarding to liquibase/entities/etc.
Why should this not be possible? MySQL itself is a multiuser DBMS, so it could handle multiple connections.
The only problem would be liquibase, because it checks if your database is valid against your changelogs. So, if your second app also uses liquibase and has not the same changelogs with same checksums, it will not start. So your second app should not use liquibase and you should remove the liquibase-stuff from the second app. The means: the first app is repsponsible for creating/updating the schema using liquibase and the second app just uses the same schema.
And you're right: the entities must be the same, because hibernate/JPA assumes the same column and entity/table names (which are given by the database)...
In my opinion, a better approach would be the microservice-way: the first application is the only who access the database directly and offers some interfaces for the entities via REST. Then, your second application simply uses the interface via a REST-Client. This also allows you to define other/modified entities via the REST-Service and your second app may not use exactly the same like in the first application.
Does it create any major problems if we always create and populate a PouchDB database locally first, and then later sync/authenticate with a centralised CouchDB service like Cloudant?
Consider this simplified scenario:
You're building an accommodation booking service such as hotel search or airbnb
You want people to be able to favourite/heart properties without having to create an account, and will use PouchDB to store this list
i.e. the idea is to not break their flow by making them create an account when it isn't strictly necessary
If users wish to opt in, they can later create an account and receive credentials for a "server side" database to sync with
At the point of step 3, once I've created a per-user CouchDB database server-side and assigned credentials to pass back to the browser for sync/replication, how can I link that up with the PouchDB data already created? i.e.
Can PouchDB somehow just reuse the existing database for this sync, therefore pushing all existing data up to the hosted CouchDB database, or..
Instead do we need to create a new PouchDB database and then copy over all docs from the existing (non-replicated) one to this new (replicated) one, and then delete the existing one?
I want to make sure I'm not painting myself into any corner I haven't thought of, before we begin the first stage, which is supporting non-replicated PouchDB.
It depends on what kind of data you want to sync from the server, but in general, you can replicate a pre-existing database into a new one with existing documents, just so long as those document IDs don't conflict.
So probably the best idea for the star-rating model would be to create documents client-side with IDs like 'star_<timestamp>' to ensure they don't conflict with anything. Then you can aggregate them with a map/reduce function.