keystonejs

Add custom fieldtype in keystone.js

。_饼干妹妹 提交于 2019-12-06 05:31:00
I am trying to add a hidden fieldtype called 'admin' which just has the user id of the person creating the model item. This works fine locally but for some reason doesn't work on a server. Here is what I did, maybe it is because I modified a file inside keystone/lib? /Models/Group.js var keystone = require('keystone'), Types = keystone.Field.Types; /** * Group Collection Model * ============= */ var Group = new keystone.List('Group'); Group.add({ name: { type: String, required: true, initial: true }, createdAt: { type: Date, default: Date.now }, groupId: { type: Types.Admin, required: true,

How to add virtual property of type Array using Keystone.js?

本秂侑毒 提交于 2019-12-04 19:39:09
问题 This is my code for my model: 'Info' and its the tokens property that creates the problem. var keystone = require('keystone'), Types = keystone.Field.Types; var Info = new keystone.List('Info'); Info.add({ title: { type: String, required: true, initial: true }, subtitle: { type: String, initial: true }, content: { type: Types.Markdown, height: 500, initial: true }, author: { type: Types.Relationship, ref: 'User', initial: true }, date: { type: Types.Date, default: Date.now, initial: true },

How to add virtual property of type Array using Keystone.js?

心不动则不痛 提交于 2019-12-03 12:43:18
This is my code for my model: 'Info' and its the tokens property that creates the problem. var keystone = require('keystone'), Types = keystone.Field.Types; var Info = new keystone.List('Info'); Info.add({ title: { type: String, required: true, initial: true }, subtitle: { type: String, initial: true }, content: { type: Types.Markdown, height: 500, initial: true }, author: { type: Types.Relationship, ref: 'User', initial: true }, date: { type: Types.Date, default: Date.now, initial: true }, published: { type: Boolean, default: false, initial: true }, tokens: { type: Array, virtual: true,

Keystone JS: S3 image uploads being auto-renamed with temporary string

醉酒当歌 提交于 2019-12-02 21:15:40
问题 I'm pretty new to Keystone as I recently inherited a codebase on a project that used it. We were locked into version 0.2.42 so I just updated to the latest, version 0.3.12 and now I'm having a strange issue. All our models with images use S3 for upload (Types.S3File) and it used to just place the image with the original file name at the root of the specified S3 bucket. Now, however, the files are being renamed with what I'm guessing is a temporary string name. For example if I upload a file

Data.model.updateItem is not a function TypeError: Data.model.updateItem is not a function

为君一笑 提交于 2019-12-02 14:32:48
问题 Error in keystone js using mongo : Vehicle.model.updateItem is not a function TypeError: Vehicle.model.updateItem is not a function . The goal is to update the model using an object just like how I did create Items using the ff. code below. CreateItems - Vehicle is the model. and postJson is the json array object. keystone.createItems({ Vehicle: postJson }, function (err, stats) { if (err) return res.json(err); res.json({ data: stats.message }); console.log("Succeeded!!") }); Now I am trying

Keystone JS , what field type we can you on saving an array of objects

99封情书 提交于 2019-12-02 12:09:39
In my program I generated an array of objects which is the ImageData , Now I want to save that data to mongo Db , I have no problem with other Keys except the ImageData key because I dont know what field type to use to be able to insert those data below which are an array of objects . What field type in keystone we could use to save those array of object example below ?. Thank you. Data Model , this is the model , I tried using Text array but it does not seem to work. Data.add({ name: { type: String, required: false }, Type: { type: Types.Select, options: 'New, Used,', index: true }, ImageData

Keystone JS: S3 image uploads being auto-renamed with temporary string

自古美人都是妖i 提交于 2019-12-02 10:29:16
I'm pretty new to Keystone as I recently inherited a codebase on a project that used it. We were locked into version 0.2.42 so I just updated to the latest, version 0.3.12 and now I'm having a strange issue. All our models with images use S3 for upload (Types.S3File) and it used to just place the image with the original file name at the root of the specified S3 bucket. Now, however, the files are being renamed with what I'm guessing is a temporary string name. For example if I upload a file called "MyImage.jpg," it will upload as something like "7830c3a6bc7b6790e63de9a3c3716b06.jpg." Is there

iterate over an array of objects in jade/pugjs

倾然丶 夕夏残阳落幕 提交于 2019-11-30 11:39:48
I have the following json object: var partners =[{ "name":"partnerx", "image": "imagex" }, { "name": "partnery", "image": "imagey" }] I want to put into a ul object using jade and I tried: ul#slides.swiper-wrapper mixin partners(name, image) li.swiper-slide img(src=#{image} , alt=#{name}) This is not working. tpae Try this: ul#slides.swiper-wrapper each partner in partners li.swiper-slide img(src=partner.image, alt=partner.name) https://pugjs.org/language/iteration.html 来源: https://stackoverflow.com/questions/24316772/iterate-over-an-array-of-objects-in-jade-pugjs