Keystonejs how to access models in a template

I created a new model and display it on the admin ui, but how can I get it from the template?

var keystone = require('keystone'),
    Types = keystone.Field.Types;


var Content = new keystone.List('Content', {
    map: {name: 'title'},
    autokey: {path: 'slug', from: 'title', unique: true }
});


Content.add({
    title: { type: String, required: false },
    state: { type: Types.Select, options: 'draft, published, archived', default: 'archived'},
    author: { type: Types.Relationship, ref: 'User', index: true },
    content: {
        brief: { type: Types.Html, wysiwyg: true, height: 100  }
    }
});

Content.defaultColumns = 'title';
Content.register();

      

+3


source to share


1 answer


var keystone = require('keystone');

exports = module.exports = function(req, res) {

var view = new keystone.View(req, res),
    locals = res.locals;

// locals.section is used to set the currently selected
// item in the header navigation.
locals.section = 'home';

// Render the view
view.query('Rekrys', keystone.list('Rekrys').model.find());
view.render('rekry');

};

      



+1


source







All Articles