meteor-mysql
meteor-mysql copied to clipboard
I try to apply meteor-mysql with socially tutorial from angular-meteor.com, how can I use meteor-mysql as collection
such as this page: https://angular-meteor.com/tutorials/socially/angular1/3-way-data-binding
It describe by use mongo as collection.
import { Mongo } from 'meteor/mongo';
export const Parties = new Mongo.Collection('parties')
and then in component file it can import like this
import { Parties } from '../collections/parties';
and can use in helper
$scope.helpers({
parties() {
return Parties.find({});
}
});
what should i do if i will use meteor-mysql? Sorry for not smart question, I've just start to learn meteor&nodejs and I need to use mysql and angular.
I was wondering the same thing and figured out a way to get this to work with angular2. From what it seems is this plugin does not use Mongo at all so you cannot use it like you do in the angular-metoer tutorials.
For angular 2 I did this.
export class HomeComponent {
appointments = new MysqlSubscription('allAppointments');
events: CalendarEvent[];
constructor(public zone: NgZone) {}
ngOnInit() {
this.appointments.addEventListener('update', (diff, data) => {
let temp = [];
for(var i = 0; i < data.length; i++) {
temp[i] = data[i];
}
this.zone.run(() => {
this.events = temp;
});
});
}
Probably not the best solution, but it works.
For angular1 you should be able to do something similar to
class PartiesList {
constructor($scope, $reactive) {
'ngInject';
$reactive(this).attach($scope);
parties = new MysqlSubscription('parties');
this.helpers({
parties() {
return parties.reactive();
}
});
}
}
I have not tested that for angular 1, but think it should be possible. Hope this helps.
Hi @Vader699
Could you please tell how you imported the appropriate modules\functions to your angular application?For example 'MysqlSubscription'?
TIA