Files
payloadcms/payload/index.js
Elliot DeNolf 5867715598 Add collections
2018-04-20 23:35:53 -06:00

43 lines
874 B
JavaScript

const path = require('path');
const Collection = require('./Collection');
class Payload {
constructor(options) {
this.app = options.express;
this.mongoose = options.mongoose;
this.baseURL = options.baseURL;
this.views = path.join(__dirname, 'views');
this.collections = {};
this.app.get(`/payload/admin`, function (req, res) {
res.render('admin',
{
title: 'Payload Admin'
})
});
}
newCollection(key) {
if (key in this.collections)
{
console.log(`${key} already exists in collections`);
return;
}
return new Collection(this, key);
}
getCollection(key) {
if (!(key in this.collections)) {
console.log(`${key} does not exist in collections or has not been registered yet`);
return;
}
return this.collections[key];
}
}
module.exports = Payload;