I'd like to use breeze but I can't find out if it will work with a MySQL + Express + Angular + Node stack. The docs say it will work with MongoDB, but what about MySQL?
Any standard SQL database like Oracle, MySQL, MariaDB, SQLServer, etc is supported out of the box as long as there is an Entity Framework Provider for it (and almost all of them do).
Source
You can integrate the Nodejs backend with Mysql using, for example node-mysql, and to integrate with Angularjs, you can do something like this:
<!-- Angular template -->
<li data-ng-repeat="emp in employees">
<label>{{emp.FirstName}}</label>
<label>{{emp.LastName}}</label>
</li>
// bound to employees from query
manager.executeQuery(breeze.EntityQuery.from("Employees"))
.then(function(data) { $scope.employees = data.results; });
#danilodeveloper I'm having to take back your answer because it isn't that simple.
There currently is no out-of-the-box support for Breeze + Node + MySQL. Simply using node-mysql to interface with the DB isn't enough. As per Ward's answer here not using an ORM would be tricky and a ton of code would need to be written along the lines of the breeze-mongodb npm module.
Related
Explanation
Today i have spotted the Delphi XE6 Sample called FireDACJSONReflect and i would to use the way it does the communication between the datasnap server and the client, i want to do it on Mine application using TFDMemTableand TFDJSONDataSets(not really needed, but if there is another way using another components i would like to see it).
** Mine application is a delphi-xe4 server and a delphi-xe6 client **
Problem
By the way, my application does use Delphi XE4 instead of Delphi XE6 and want to know what to do to communicate between the datasnap server and the client the same way that FireDACJSONReflect does but i see that i cant have TFDJSONDataSets on my project uses list.
Can i use TFDJSONDataSets on Delphi XE4?
Can i use TFDMemTable without using TFDJSONDataSets to populate it with data?
Some code
I have that lines of code running ok on delphi xe6 and i want to do the same in xe4:
function TDSSMetodoFinanceiro.getCotacaoLista : TFDJSONDataSets;
var
FDQCotacaoLista : TADQuery;
begin
Result := TFDJSONDataSets.create;
TFDJSONDataSetsWriter.listAdd(result, FDQCotacaoLista);
end;
And the question: Why i want to result a TFDJSONDataSet?
Its because i have a TFDMemTable on my delphi xe6 client application that i want to .appendData and it needs a TFDJSONDataset to do it(maybe another way to append data do it is useful).
Any help?
TFDJSONDatasets is, I believe, introduced in XE6, so you cannot use this in earlier versions like XE4. However, I think the job can be done with a FDMemtable instead.
Check out this tutorial, it was written for XE5 but I think this must work in XE4 too.
It starts of from some other example using a Clientdataset, but is then reworked to use a Firedac Memory table.
I should say, give it a try and see if it works out for you.
Stack: MySQL + Express + Angular + Node and node-mysql to talk to the DB.
EDIT: I'm connectiong to a local DB and the connection works. I can't get Breeze to communicate with it.
I'm trying to get the Breeze Todo app to work with this setup but I'm getting a localhost:3000/ToDos? 404 (Not Found) when Breeze goes out to get the data.
Do I need to create the API for Breeze to talk to? I've tried this:
angular.module('mysql', ['ngResource']).
factory('ToDos', function($resource) {
var ToDos = $resource('/ToDos', {}, {update:{method:'PUT'}});
return ToDos
});
And then injecting it into the datacontext service here:
angular.module('mainApp').factory('datacontext',
['$http', 'logger', 'breeze', 'ToDos', datacontext]);
function datacontext($http, logger) {
var dataService = new breeze.DataService({
serviceName: '/ToDos',
hasServerMetadata: false
});
var manager = new breeze.EntityManager({
dataService: dataService
});
...
}
I'm pretty lost as to what I'm doing wrong. Any help would be appreciated.
EDIT: The comments informed me that the backend API needs to be created. I'm working on that but could use some help converting the breeze-mongodb module.
In Breeze's zza example in repository.js there are calls to this module's MongoQuery() and MongoSaveHandler() functions. Would it be as simple as converting them to MySQL connection.query? And any help in the conversion would be much appreciated!
I'm very curious about your progress on this. It's quite ambitious.
Ultimately I believe you'll be writing something like the "breeze-mongodb" npm module which will have a query and save implementation attuned to MySQL.
It could be tricky without an ORM. If you choose to go with an ORM in Node for MySQL (node-orm???), you can learn a lot about what to do from the Breeze source code for ContextProvider, ContextProvider.EF and ContextProvider.NH in the "breeze.net.server" repo on github. You don't have to be a C# person to glean transferable insights from that code base.
Is there any frontend application sample that consumes RESTful services of Spring-data-rest backend which is written with angularJS.
My prefer for rest api for angularjs is RESTANGULAR module...
In the site you can see many examples that how they deal with Rest calls and really good documentation and good community as well...
In this example which is from spring example SPRING.IO they uses $http, but I should say that Restangular uses $http as well, so basically you can say that Restangular is extended version of $http...
and for the last you can look for $resource...
I will update my answer If I will find something new...
Here are some links to AngularJS apps consuming Spring RESTful services
https://github.com/spinner0815/spring-data-rest-angularjs
At the moment, I think that angular-hal is the best library to consume Spring Data Rest output and stay with its philosophy of discovering url through relations.
The home page: https://github.com/LuvDaSun/angular-hal
and some examples :
https://github.com/LuvDaSun/angular-hal/tree/master/demo (by the dev)
https://www.jiwhiz.com/blogs/Consume_RESTful_API_With_Angular_HAL
https://github.com/paulcwarren/gs-rolebased-ui-with-hypermedia
here has a nice lib spring-data-rest-js can help you.
It's a easy to use and lightweight javascript lib can run in both node.js and browser. After use this lib you can manage entity like this way:
let springRest = require('spring-data-rest-js');
let Student = springRest.entity.extend('students');
let student = new Student();
student.set('name', 'Tom');
//create entity
student.save().then(()=> {
//update entity
student.set('name', 'Physics');
retuen student.save();
}).then(()=> {
//delete entity
retuen student.delete();
}).catch(err=> {
done(err);
})
base on fetch API and Promise,inspired by Parse.
It can be work with lib like AngularJS React Vue...
Is there any way to implement ACL using Silex, but without Doctrine ORM?
Using entities we can handle this like this
$oidd = new Symfony\Component\Security\Acl\Domain\ObjectIdentity::fromDomainObject($message(\);
$acl = $app['security.acl.provider']->createAcl($oidd);
// the current user is the owner
$sid = Symfony\Component\Security\Acl\Domain\UserSecurityIdentity::fromAccount($currentUser);
$acl->insertObjectAce($sid, Symfony\Component\Security\Acl\Permission\MaskBuilder::MASK_OWNER);
Any solutions?
You might want to have a look at this example project.
https://github.com/davedevelopment/silex-acl-demo
The relevant bootstrap code is here (and works for me with Silex 1.2):
https://github.com/davedevelopment/silex-acl-demo/blob/master/app/bootstrap.php#L59
From the README:
This is a demo of Symfony's ACL using Silex. I've tried
to annotate the services in app/bootstrap.php, but to be honest, I
originally reverse engineered the symfony full stack frameworks DI
configuration without fully understanding what everything does, still
don't!
I'm trying to use entity framework with an adapter structure, my goal will be to have a single .edmx structure able to manage several connections.
I need to have those adapters:
file based database (SqlServerCE 3.5)
MySql (with its custom provider from Oracle)
Oracle (as MySql)
SqlServer
I have a DAO class that receives a bean (dependency injection object) with data connection from a winform, than due to a specific info in that bean, the DAO will load the correct adapter, through a Database factory class.
My Database factory will load a real adaptor class (e.g. for mysql A_Mysql.cs that implement my abstract adapter class).
In particular, I would like to understand hop I can modify in the adaptor the connection method:
public override Entities createConnection(DbConnection dbBean)
{
string conn =
#"metadata=res://*/Toolkit.Database.External.ADO.ADODatabase.csdl" +
#"|res://*/Toolkit.Database.External.ADO.ADODatabase.ssdl" +
#"|res://*/Toolkit.Database.External.ADO.ADODatabase.msl;" +
#"provider=MySql.Data.MySqlClient;" +
"provider connection string=\"Persist Security Info=True;server=" + dbBean.Server + ";" +
"Port=" + dbBean.Port + ";" +
"User Id=" + dbBean.Username + ";"+
"Password=" + dbBean.Password + ";" +
"database=" + dbBean.Schema + "\"";
Entities entities = new Entities(conn);
return entities;
}
to use the same .edmx, in my DAO…
I was pretty sure that this was the right way, unfortunately this system is always returning me errors from SqlCE (I have generated the first .emdx from SqlServerCE, but it does not contain any informations about that database and my App.config file has NOT stored database informations)…
Can you help me? Please write me back for further information, if needed.
Thank you.
Your data access layer will need to be abstracted at the entity provider level, not the database connection level. You're basically talking about using the repository pattern. You will need to have a separate context for each provider you plan to support, because that's ultimately what's responsible for translating your Linq queries into the correct SQL syntax for a specific database platform. Each context should implement the same interface (which is your repository interface). In your code, you do everything against that interface, not the actual context types. Then use a Dependency Injection framework (such as Ninject) to manage instantiating the correct context implementation for the database provider you're using.
It will not work because EDMX itself contains information about database provider. Also whole database description stored in EDMX targets single database provider. There is even difference between SQL Server 2005 and 2008. You need at least separate SSDL part for every database you want to support.
I've a post on mi site on how to use multiple connection to multiple databases [it's in spanish :)]
Post
Regards.