2019-03-29 02:47:11 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Note from '/imports/api/note';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
|
|
|
|
export default function addNote(meetingId, noteId, readOnlyNoteId) {
|
|
|
|
check(meetingId, String);
|
|
|
|
check(noteId, String);
|
|
|
|
check(readOnlyNoteId, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
2019-06-01 04:02:33 +08:00
|
|
|
noteId,
|
2019-03-29 02:47:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
meetingId,
|
|
|
|
noteId,
|
|
|
|
readOnlyNoteId,
|
2019-06-01 04:02:33 +08:00
|
|
|
revs: 0,
|
2019-03-29 02:47:11 +08:00
|
|
|
};
|
|
|
|
|
2020-11-23 21:13:46 +08:00
|
|
|
try {
|
|
|
|
const { insertedId } = Note.upsert(selector, modifier);
|
2019-03-29 02:47:11 +08:00
|
|
|
|
2020-11-23 21:13:46 +08:00
|
|
|
if (insertedId) {
|
|
|
|
Logger.info(`Added note id=${noteId} readOnlyId=${readOnlyNoteId} meeting=${meetingId}`);
|
|
|
|
} else {
|
|
|
|
Logger.info(`Upserted note id=${noteId} readOnlyId=${readOnlyNoteId} meeting=${meetingId}`);
|
2019-03-29 02:47:11 +08:00
|
|
|
}
|
2020-11-23 21:13:46 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Adding note to the collection: ${err}`);
|
|
|
|
}
|
2019-03-29 02:47:11 +08:00
|
|
|
}
|