keystonejs

Unpopulated fields between two Schemas keystone.js

三世轮回 提交于 2019-12-12 23:23:18
问题 I have two models: Entity and Cabinet. Entity model can have multiple cabinets. One cabinet can have one Entity object. In my admin UI when I create Cabinet I specify the Entity which the cabinet belongs to. I have linked Entity to Cabinets and Cabinets to Entity like this: models/Entity.js Entity.add({ name: { type: Types.Text, initial: true, label: 'Име' }, cabinets: { type: Types.Relationship, ref: 'Cabinet', many: true }, }) models/Cabinet.js Cabinet.add({ entity_id: { type: Types

Implementing multitenancy in KeystoneJS

懵懂的女人 提交于 2019-12-12 05:25:30
问题 How can KeystoneJS be used to implement multi-tenancy? Is it possible at all? Example use case: A company is creating a new blog platform using KeystoneJS and it wants to allow for multiple blog sites using the same models from one KeystoneJS instance but each blogger should only be able to control their own site. 回答1: Keystonejs does not really support this. Something that you could do, however, is to use something like Docker with an image of the Keystonejs website, then add some

Why am I getting an empty repo when cloning my keystone app to local repo from heroku?

蹲街弑〆低调 提交于 2019-12-12 03:34:53
问题 I first used the following link to create a new Keystone app from Heroku: https://dashboard.heroku.com/new?button-url=https%3A%2F%2Ft.co%2FjbNu7UtZpn&template=https%3A%2F%2Fgithub.com%2FJedWatson%2Fkeystone-starter Then I wanted to clone it to my local repo: ➜ Nodejs heroku git:clone -a yellowkorner Cloning from app 'yellowkorner'... Cloning into 'yellowkorner'... warning: You appear to have cloned an empty repository. Checking connectivity... done But when I cd into the folder it's an empty

how to correctly reference a js file in a ejs file in Angular

北城以北 提交于 2019-12-12 01:28:46
问题 This is my project structure: public -js --angular.min.js --angularApp.js templates -views --index.ejs This is my index.ejs file: <html> <head> <title>My Angular app!</title> <script type='text/javascript' src="../../public/js/angular.min.js"></script> </head> <body ng-app="flapperNews" ng-controller="MainCtrl"> <div> {{test}} </div> <script type='text/javascript' src="../../public/js/angularApp.js"></script> </body> </html> When I run this I get a 404 not found error on the js files. I tried

Nodejs Multer diskStorage not working - why destination targeting temp folder and not uploading

我们两清 提交于 2019-12-11 18:41:37
问题 I am using Multer to upload a profile image and unfortunately not working correctly. This is my code: var express = require("express"); var multer = require('multer'); var app = express(); var storage = multer.diskStorage({ destination: function (req, file, callback) { callback(null, './public/uploads'); }, filename: function (req, file, callback) { callback(null, file.fieldname + '-' + Date.now()); } }); var upload = multer({ storage : storage}).single('avatar'); exports.uploadAvatar =

Does Keystone JS supports nested schema inside of that array?

自作多情 提交于 2019-12-11 18:25:15
问题 Does Keystone JS supports nested schema inside of that array ? I tried adding one but it gives me an error Fields must be specified with a type function. Because I am trying to save an array of objects but I have problem on what field type or schema of the model. Is there a way in keystone to be able to save that data below which is an array of objects ? does the keystone model supports it ? is there a workaroung ? Sample - The Image Data model is a nested schema but it gives an error fields

How to upload S3 files in KeystoneJS

半城伤御伤魂 提交于 2019-12-11 12:48:50
问题 I have an item called style which has 2 attributes, one which has raw css text and another which has an S3File. Style.add({ ... css: { type: Types.Code, language: 'css' }, cssFile: { type: Types.S3File, s3path: 'uploads/assets', }, ... }); I want to update the S3File with the contents of the css text. function uploadCSStoAmazon(style) { // Store css code in temporal file (with a md5 name) var rndm = crypto.randomBytes(20).toString('hex'), file_path = '/tmp/css_temp_' + rndm + '.css'; fs

How to show uploaded image in Keystonejs back-end

旧城冷巷雨未停 提交于 2019-12-11 08:15:31
问题 Very similar to problem here but I'm not using S3 files and the info in that link is somewhat dated (hasn't been updated since github issues linked from question above were closed). My question is about how to get a preview of an uploaded image in Keystonejs's admin back-end. Although it seems like it's a hacky fix (editing keystone files as suggested in link above) I'm wondering if there's other options. Although they've added support for S3 files and Types.CloudinaryImage is supported I can

KeystoneJS: How to set a field to receive randomly generated value?

旧时模样 提交于 2019-12-11 06:50:10
问题 I'm creating a model that I will use to authenticate users for API access, and I have a secret field where I want to store a Base64 encoded uuid/v4 generated value. I went through the different field types and options, but still not seeing how I could achieve this. Is there a way to hook in model instance creation, and set the value of my secret field ? 回答1: Yes, you can use the pre hooks. In your situation, the basics would be: AuthenticationModel.schema.pre("save", function(next) { const

KeystoneJS: Relationships in Admin UI not updating

旧巷老猫 提交于 2019-12-11 03:03:03
问题 I am customizing KeystoneJS and I have run into an issue where it seems the relationship lists in my Admin UI have failed to update. Specifically, I am looking at the default Post and Post Categories models with a relationship defined on the Post.categories field. If I add a category, it does not show up as an option for when creating or editing a Post. Could there be some kind of data caching going on? Has anyone seen this issue, I am not seeing any errors and I can confirm the category has