Merged the AssetAssignment collection with the Asset collection; Updated views for assigning assets; Added view to find asset assignments by assetId.

This commit is contained in:
2022-08-14 17:07:14 -07:00
parent f3b1b38e82
commit cf51200393
13 changed files with 3897 additions and 53 deletions

View File

@@ -4,7 +4,7 @@ import { Roles } from 'meteor/alanning:roles';
import {check} from "meteor/check";
import {Sites} from "/imports/api/sites";
import {parse} from "csv-parse";
import {Students} from "/imports/api/students";
import { ReactiveAggregate } from 'meteor/tunguska:reactive-aggregate';
export const Staff = new Mongo.Collection('staff');
@@ -13,6 +13,15 @@ if (Meteor.isServer) {
Meteor.publish('staff', function(siteId) {
return Staff.find({siteId});
});
Meteor.publish('staffWithAssetAssignments', function(query) {
ReactiveAggregate(this, Staff, {$lookup: {
from: 'assetAssignments',
localField: '_id',
foreignField: 'assigneeId',
as: 'assignments'
}}, {});
//Note: The options can use {clientCollection: 'your_name_here'} as the options to change the collection name on the client.
});
}
Meteor.methods({
'staff.add'(firstName, lastName, email, siteId) {