Tag: keystonejs

如何从admin部分在keystone.js中创build页面

我是新的node.js以及keystone。 我想创build一个新的模型称为页面相同的职位是从梯形默认。 我创build的新模型是代码 var pages = new keystone.List('pages', { map: { name: 'title' }, autokey: { path: 'slug', from: 'title', unique: true } }); pages.add({ title: { type: String, required: true }, state: { type: Types.Select, options: 'draft, published, archived', default: 'published', index: true }, author: { type: Types.Relationship, ref: 'User', index: true }, publishedDate: […]

获取keystone中的相关项目

在KeystoneJS的一个项目上工作,我很难搞清楚mongoose的关系。 根据keystone文档,假设我们有以下模型: User和Post 。 现在一个post与用户有关系,所以我会写: Post.add({ author: { type: Types.Relationship, ref: 'User' } }); 接着: User.relationship({ path: 'posts', ref: 'Post', refPath: 'author' }); 现在,我希望能够查看与该用户相关的所有post,而不必同时查询用户和post。 例如,如果我查询用户对象,我希望能够做user.posts并有权访问这些相关的职位。 你可以用mongoose/基石做这个吗?

Keystone JS中的validation错误

我试图build立一个非常相似的keystone演示中使用的联系表单,但我已经打了一个路障,虽然试图保存到分贝,我得到以下错误 { message: 'Validation failed', name: 'ValidationError', errors: { name: { name: 'ValidatorError', path: 'name', message: 'Name is required', type: 'required' } } } 我已经检查了窗体上的字段和请求在后台做了一个console.log,但由于某种原因,我仍然继续得到相同的错误。 这是我的玉档 section#contact-container section#contact.contact-us .container .section-header // SECTION TITLE h2.white-text Get in touch // SHORT DESCRIPTION ABOUT THE SECTION h6.white-text | Have any question? Drop us a message. We will get […]

Mongoose ValidationError在Passport KeystoneJS中创build新用户

我在我的项目中使用KeystoneJS的Passport身份validation插件 。 如果用户帐户存在并且与正在使用的社交networking绑定,那么一切都很好。 当创build一个新用户时,使用config选项'auto create user': true ,最后在oauthcallback路由上出现500错误。 日志说这是一个validation错误。 ValidationError: Validation failed at model.Document.invalidate (/app/node_modules/keystone/node_modules/mongoose/lib/document.js:1021:32) at /app/node_modules/keystone/node_modules/mongoose/lib/document.js:970:16 at validate (/app/node_modules/keystone/node_modules/mongoose/lib/schematype.js:610:7) at /app/node_modules/keystone/node_modules/mongoose/lib/schematype.js:627:9 at Array.forEach (native) at SchemaString.SchemaType.doValidate (/app/node_modules/keystone/node_modules/mongoose/lib/schematype.js:614:19) at /app/node_modules/keystone/node_modules/mongoose/lib/document.js:968:9 at process._tickCallback (node.js:419:13) 什么可能导致这个? 编辑 用户型号: var keystone = require('keystone'), Types = keystone.Field.Types, social = require('keystone-social-login'); /** * User Model * ========== */ var User […]

KeystoneJS中间件使用Model.find()调用MongoDB时运行两次

我有一个路线,加载一个公寓列表,并显示它们: app.get( '/condo-list', middleware.loadCondoList, routes.views.condolist ); loadCondoList中间件调用CondoBuilding模型并在res.locals上设置结果: exports.loadCondoList = function loadCondoList( req, res, next ) { console.log( 'request url: ' + req.url ); console.log( 'getting condo buildings…' ); CondoBuilding.model .find() .exec( ( err, condos ) => { if ( err ) { // pass error along next( err ); } else { // add CondoBuildings […]

将项目名称添加到keystone.js中的关系字段中

有没有人有一个很好的例子,在keystonejs中的关系字段添加名称? 现在它只是保存一个ID,所以如果我需要显示在玉模板中的字段名称我也需要查询该关系模型。 理想情况是这样的: var keystone = require('keystone'), Types = keystone.Field.Types; /** * Titles Model * ============= */ var Title = new keystone.List('Title'); Title.add({ name: { type: String, required: true, initial: true }, room: { type: Types.Relationship, initial: true, required: true, ref: 'Screening', addNew: false }, businessUnit: { type: Types.Relationship, initial: true, required: true, ref: 'BusinessUnit', […]

有没有办法在Keystone.js中隐藏ID列?

我遇到了麻烦,试图隐藏由Keystone List模板自动生成的ID列。 有没有办法抑制这一列? 这个文档很less涉及框架的基本用法。

如何在Keystone.js数据库ODM中创buildstring数组?

如何在Keystone.js数据库ODM中创buildstring数组? 我必须创造一个单一领域的新模式,只与他build立many:true关系?

我如何testingkeystonejs模型?

有什么办法可以运行testingkeystonejs也打一个testing或真正的MongoDB实例吗? 如果类似于Django的方式,那将会很好。

遍历jade / pugjs中的对象数组

我有以下json对象: var partners =[{ "name":"partnerx", "image": "imagex" }, { "name": "partnery", "image": "imagey" }] 我想用玉来放入一个ul对象,我试过了: ul#slides.swiper-wrapper mixin partners(name, image) li.swiper-slide img(src=#{image} , alt=#{name}) 这不起作用。