Skip to content

Instantly share code, notes, and snippets.

@acomito
Created December 8, 2016 14:19
Show Gist options
  • Save acomito/28c444394597f98f99cc4f4699f7d6d4 to your computer and use it in GitHub Desktop.
Save acomito/28c444394597f98f99cc4f4699f7d6d4 to your computer and use it in GitHub Desktop.
import { Meteor } from 'meteor/meteor';
import { Roles } from 'meteor/alanning:roles';
import { Accounts } from 'meteor/accounts-base';
import Video from '../../api/video/video';
const users = [{
email: 'admin@admin.com',
password: 'password',
profile: {
name: { first: 'Carl', last: 'Winslow' },
},
roles: ['admin'],
}];
users.forEach(({ email, password, profile, roles }) => {
const userExists = Meteor.users.findOne({ 'emails.address': email });
if (!userExists) {
const userId = Accounts.createUser({ email, password, profile });
Roles.addUsersToRoles(userId, roles);
}
});
let videoExists = Video.find().fetch();
console.log(videoExists.length);
if (!videoExists || videoExists.length === 0) {
let docToInsert = {
_id: '1',
sessionOn: false,
};
Video.insert(docToInsert, {}, function(error, response){
if (error) { console.log(error); return; }
console.log('inserted');
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment