Converted sample project into an almost working Svelte / Meteor project. Needs to fix the login/logout code, the camera code, and add Chromebook history when the QR Code is scanned.
This commit is contained in:
52
imports/api/data-collection.js
Normal file
52
imports/api/data-collection.js
Normal file
@@ -0,0 +1,52 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Mongo } from 'meteor/mongo';
|
||||
import { check } from 'meteor/check';
|
||||
import { MongoClient } from 'mongodb';
|
||||
|
||||
//export const Records = new Mongo.Collection('records');
|
||||
let client;
|
||||
let database;
|
||||
let dataCollection;
|
||||
|
||||
if (Meteor.isServer) {
|
||||
let uri = process.env.MONGO_URL2;
|
||||
|
||||
client = new MongoClient(uri);
|
||||
database = client.db("avusd-data-collection");
|
||||
dataCollection = database.collection("records");
|
||||
|
||||
// This code only runs on the server
|
||||
Meteor.publish('chromebookData', function(deviceId) {
|
||||
check(deviceId, String);
|
||||
|
||||
return dataCollection.find({deviceId});
|
||||
});
|
||||
}
|
||||
|
||||
Meteor.methods({
|
||||
// 'tasks.setChecked'(taskId, setChecked) {
|
||||
// check(taskId, String);
|
||||
// check(setChecked, Boolean);
|
||||
//
|
||||
// const task = Tasks.findOne(taskId);
|
||||
// if (task.private && task.owner !== this.userId) {
|
||||
// // If the task is private, make sure only the owner can check it off
|
||||
// throw new Meteor.Error('not-authorized');
|
||||
// }
|
||||
//
|
||||
// Tasks.update(taskId, { $set: { checked: setChecked } });
|
||||
// },
|
||||
// 'tasks.setPrivate'(taskId, setToPrivate) {
|
||||
// check(taskId, String);
|
||||
// check(setToPrivate, Boolean);
|
||||
//
|
||||
// const task = Tasks.findOne(taskId);
|
||||
//
|
||||
// // Make sure only the task owner can make a task private
|
||||
// if (task.owner !== this.userId) {
|
||||
// throw new Meteor.Error('not-authorized');
|
||||
// }
|
||||
//
|
||||
// Tasks.update(taskId, { $set: { private: setToPrivate } });
|
||||
// },
|
||||
});
|
||||
Reference in New Issue
Block a user