With Graphcool is it possible to view the SQL database to see your tables, rows, items etc?
My application will use GraphQL queries (obviously!) but as an admin it would be handy for me to be able to see my entire database.
{
allGroups{
name
id
}
}
In the terminal run graphcool console from your server directory. There is then a data menu link in the page that opens.
Related
it took me days to figure this out:
I am using azure mobile apps as my backend.
I created a middleware that connects to my sql db. this is appdbcontext.cs:
public class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
{
}
public DbSet<TodoItem> TodoItems => Set<TodoItem>();
public DbSet<UserItem> UserItems => Set<UserItem>();
public async Task InitializeDatabaseAsync()
{
await this.Database.EnsureCreatedAsync().ConfigureAwait(false);
}
}
When I deploy this script to azure and check my tables inside SSMS both tables are created. (Todo and UserItems)
I can read and write to them, so my controllers and models are all fine!
HOWEVER:
If I now create a third table eg:
public DbSet<ThirdItem> ThirdItem => Set<ThirdItem>();
And then check the DB in SSMS I still just see the two tables from above.
If i now however delete alle the existing tables (todo and user), so that there are NO MORE TABLES on my db and THEN deploy my script to azure again...
ALL THREE TABLES ARE THERE NOW?!?
So meaning I must do something wrong in the app context file, as it somehow checks:
"Do we already HAVE a db with tables? No, then create the following. YES? then do nothing and create nothing new".
How can I alter my script to check if a table exists IRREGARDLESS of whether any tables exists, and then add it to the db?
ALSO:
When I add a new field to my model I have to delete all tables so that my tables now have the new fields...
I'm developing a Xamarin.Forms app which uses an Azure app service with SQL database linked through EasyTables. I've run the samples and successfully tested querying tables etc on the server and enabled offline sync so as a localdb is created.
I've created the store, defined the table & sync'd it, however I want to be able to query it somehow with a where clause - is that possible? Can I add a where clause to the client.GetSyncTable line?
var store = new MobileServiceSQLiteStore("localstore.db");
store.DefineTable<Journey_Stages>();
client.SyncContext.InitializeAsync(store);
tbl_Stages = client.GetSyncTable<Journey_Stages>();
Some of the tables I'm pulling down will grow over time & are linked to individual user profiles, so I only want data which belongs to that user and I don't want to be bringing down masses of data each time, preferably let the server handle that and only bring down what I need on a user by user basis.
Thanks,
Steve
You should add this filtering logic on the server side, so that each user's data isn't exposed to all your other users. See for example this sample if you are using the Node.js backend -- line 17 adds a WHERE clause for the table read query. If you have the .Net backend, similar logic would go in your table controller.
// Configure specific code when the client does a request
// READ - only return records belonging to the authenticated user
table.read(function (context) {
context.query.where({ userId: context.user.id });
return context.execute();
});
I'm working on an Angular2 project (Resource Management) which requires data from the database (mongoDB) in real time. The basic function of the application is to drag a resource from bench and drop it to a project. After which a button is clicked which saves these values to the database. The problem is once the database is hit with the values, the same is not showing up unless the page is refreshed. Is there a way where we can pull data from the database without manually refreshing the entire page or pulling the data from DB at regular intervals so that the services have the latest data. I'm attaching my code here: Resource Management (drag n drop)
Thank you!!
If you want to get the data periodically.You can use timer.
ngOnInit() {
this.timer = Observable.timer(2000,5000);
// subscribing to a observable returns a subscription object
this.sub = this.timer.subscribe(t => this.geData(t));
}
geData(t) {
console.log(t)
}
You Could use socket.io for real time update with angular2 and mongodb
I am currently working on an inventory management software in Node js and MongoDB. I am pretty new to MongoDB, having worked in Oracle and MySQL for most of my projects.
Is it possible to create a separate database schema for every client who uses my software, with each client having access only to his copy of the database schema and collections?
The equivalent of selecting data in Oracle database would be
Select * from User1.table,
Select * from User2.table etc
Also, if it were possible, how would it be implemented using a node js mongo db client like mongoose?
I looked at MongoDB documentation, but it talks mainly about adding users to a database for authorization.
I apologize if it seems like a silly question, but id appreciate it if someone could point me in the right direction for this.
Before starting to invest a lot of time in the development of your project, check out other possible approaches to the scenario that you are trying to build.
I did a quick search on SO and found some additional threads with similar scenarios:
MongoDB Database vs. Collection
MongoDB Web App - Database per User
Additional info about mongoose database creation
Whenever you call the connect method on the mongoose object, you are either connecting to an existing database or you are creating it in case it doesn't already exist.
You could have a function that allows you to pass in a name argument with the name and create databases programmatically:
function createDatabase(name) {
var conn_string = 'mongodb://localhost/';
if (typeof name == 'string') {
conn_string += name;
}else{
return false;
}
mongoose.connect(conn_string);
}
Also, be aware that a database will be created when you first insert a record in a collection of that particular database.
It is not sufficient to only connect to the database, you also have to insert a record.
As per my previous example, you could also pass a schema parameter to the function, tailored to each user's profile and fire an insert statement after you connect to that database.
we have recently adopted to sql server 2008r2 from access. We are completely new to it. We need to work on data which comes in excel spreadsheets. In access we directly link the data to it and run the queries. This similar approach is available in sql server also? If not how to link the excel files into sql server?
what is sql server compact?
In order to link the excel files : In excel go to data tab. There you will find the From Other Sources option. A wizard will appear requesting the Server name and your credentials to the db -> next -> select the db you want to connect to and then the table and click finish.
Hope it helps.
I don't know about "linking" your Excel workbook or sheets to SQLServer database. Are these always on the same host?
In any case, you can easily import your Excel data into a SQLServer table:
INSERT INTO sp_configure 'Show Advanced Options', 1;
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
GO
EXEC sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
GO
EXEC sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1
GO
INSERT INTO dbo.YOUR_SQL_TABLENAME
SELECT EXCEL_COLUMN_NAME1 [, EXCEL_COLUMN_NAME2...] FROM
OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0',
'Data Source=C:\YOUR_EXCEL_FILENAME.xlsx;Extended Properties=Excel 12.0')...[Sheet1$]
This will import from Sheet1$, if you have named your worksheets, then use the name.