Skip to content

Instantly share code, notes, and snippets.


Vinaya Sathyanarayana VinayaSathyanarayana

View GitHub Profile
VinayaSathyanarayana / Example.js
Created Nov 29, 2017 — forked from flowck/Example.js
[Keystone.js] Use admin forms outside admin #671
View Example.js
// Model
var keystone = require('keystone'),
Types = keystone.Field.Types;
// Set new model
var Example = new keystone.List('Example', {
nocreate: true
// Set the fields of your model
VinayaSathyanarayana / gulpfile.js
Created Nov 15, 2017 — forked from stevenkaspar/gulpfile.js
KeystoneJS SASS Development Gulpfile
View gulpfile.js
* gulp file that will restart keystonejs app and compile sass
'use strict';
var gulp = require('gulp');
var watch = require('gulp-watch');
var shell = require('gulp-shell')
var sass = require('gulp-sass');
VinayaSathyanarayana / Reserve - model.js
Created Nov 15, 2017
Reservation Flow - KeystoneJS help
View Reserve - model.js
var keystone = require('keystone');
var Types = keystone.Field.Types;
* Hybrid from the model from the example contact and from SydJS example
* Reservation Model
* =============
VinayaSathyanarayana /
Created Nov 15, 2017 — forked from JedWatson/
Proposal: adding reverse-relationship population to Mongoose (as implemented in KeystoneJS)

I've developed a useful feature in KeystoneJS that lets you populate a relationship from either side, while only storing the data on one side, and am looking for feedback on whether it is something that could / should be brought back into mongoose itself. (It might be possible to add as a separate package but I suspect there'd be too much rewriting of mongoose internals for that to be a good idea).

I've added this as an issue in mongoose for consideration: #1888 but am leaving this gist in place because the examples are easier to read.

I've used Posts and Categories as a basic, contrived example to demonstrate what I'm talking about here; in reality you'd rarely load all the posts for a category but there are other real world cases where it's less unreasonable you'd want to do this, and Posts + Categories is an easy way to demo it.

The problem

The built-in population feature is really useful; not just for

View related.js
VinayaSathyanarayana / models-Page.js
Created Nov 15, 2017 — forked from timboslice69/models-Page.js
Role based security in KeystoneJS
View models-Page.js
var keystone = require('keystone'),
// pull in the schemaPermissions lib
// rootRequire is a custom function that fixes the path to always be from the root of the application
schemaPermissions = rootRequire('lib/schemaPermissions'),
Types = keystone.Field.Types;
* Page Model
* ==========
VinayaSathyanarayana / RepeatableFields.js
Created Nov 15, 2017 — forked from ryannhg/RepeatableFields.js
Used for expanding KeystoneJS fields, and flattening the response
View RepeatableFields.js
const getRange = (start, end) => {
let list = []
if (start <= end) {
for (let i = start; i <= end; i++)
return list
const RepeatableField = (fields, prefix) => ({
VinayaSathyanarayana / keystone.js
Created Nov 15, 2017 — forked from riyadhalnur/keystone.js
Add more options to the express app when using KeystoneJS
View keystone.js
var keystone = require('keystone');
var express = require('express');
var body = require('body-parser');
var helmet = require('helmet');
var app = express();
app.use(body.urlencoded({ extended: false }));
VinayaSathyanarayana / signup.jade
Created Nov 15, 2017 — forked from robksawyer/signup.jade
A pretty basic registration form for KeystoneJS.
View signup.jade
// @file signup.jade
// @path /templates/views/user/signup.jade
// @description Form that user sees when signing up.
extends ../../layouts/default
block intro
h1= 'Sign up for Little B.O.M'
You can’t perform that action at this time.