Added some code for searching for assignments. Needs a lot more.

This commit is contained in:
2022-08-14 13:18:50 -07:00
parent c96b4a6901
commit f3b1b38e82
3 changed files with 92 additions and 3684 deletions

View File

@@ -39,16 +39,29 @@ AssetAssignments.attachSchema(AssetAssignmentsSchema);
if (Meteor.isServer) {
// Drop any old indexes we no longer will use. Create indexes we need.
//try {AssetTypes._dropIndex("name")} catch(e) {}
//AssetTypes.createIndex({name: "text"}, {name: "name", unique: false});
AssetTypes.createIndex({assetId: 1}, {name: "AssetID", unique: false});
//try {AssetAssignments._dropIndex("name")} catch(e) {}
//AssetAssignments.createIndex({name: "text"}, {name: "name", unique: false});
try {AssetTypes._dropIndex("AssetID")} catch(e) {} //Typo put this as an index in AssetTypes instead of AssetAssignments.
AssetAssignments.createIndex({assetId: 1}, {name: "AssetID", unique: false});
// This code only runs on the server
Meteor.publish('assetAssignments', function() {
return AssetAssignments.find({});
Meteor.publish('assetAssignments', function(assetId) {
let query = {};
if(assetId) {
query.assetId = assetId;
}
return AssetAssignments.find(query);
});
}
Meteor.methods({
'AssetAssignments.getOne'(assetId) {
check(assetId, String);
return AssetAssignments.findOne(assetId);
},
/**
* Assigns the asset to the assignee. The assignee should either be a Student or Staff member.
* @param assetId The Mongo ID of the asset (asset._id).