Refactor: Migrate cursors for the Meteor 3.0 api

This commit is contained in:
Tainan Felipe 2023-03-16 10:14:05 -03:00 committed by Ramón Souza
parent 2bb7235836
commit 8b1565f2c9

View File

@ -1,38 +0,0 @@
import Logger from '/imports/startup/server/logger';
import Cursor from '/imports/api/cursor';
import { check } from 'meteor/check';
export default function updateCursor(meetingId, whiteboardId, userId, x = -1, y = -1) {
check(meetingId, String);
check(userId, String);
check(x, Number);
check(y, Number);
const selector = {
meetingId,
whiteboardId,
userId,
};
const modifier = {
$set: {
meetingId,
whiteboardId,
userId,
x,
y,
},
};
try {
const { insertedId } = Cursor.upsert(selector, modifier);
if (insertedId) {
Logger.info(`Initialized cursor meeting=${meetingId}`);
} else {
Logger.debug('Updated cursor ', { meetingId });
}
} catch (err) {
Logger.error(`Upserting cursor to collection: ${err}`);
}
}