How to use the keystone.List function in keystone

To help you get started, we’ve selected a few keystone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github VelizarMihaylov / medium-keystone-react-cms / server / models / users.js View on Github external
var keystone = require('keystone');
var Types = keystone.Field.Types;

// First we gonna create our User list
var User = new keystone.List('User');

// Then we gonna add the fields
User.add({
	name: { type: Types.Name, required: true, index: true },
	email: { type: Types.Email, initial: true, required: true, index: true },
	password: { type: Types.Password, initial: true },
	canAccessKeystone: { type: Boolean, initial: true },
});

User.register();
github keystonejs / keystone-starter / models / User.js View on Github external
var keystone = require('keystone');
var Types = keystone.Field.Types;

/**
 * User Model
 * ==========
 */

var User = new keystone.List('User');

User.add({
	name: { type: Types.Name, required: true, index: true },
	email: { type: Types.Email, initial: true, required: true, index: true },
	password: { type: Types.Password, initial: true, required: true }
}, 'Permissions', {
	isAdmin: { type: Boolean, label: 'Can access Keystone', index: true }
});

// Provide access to Keystone
User.schema.virtual('canAccessKeystone').get(function() {
	return this.isAdmin;
});


/**
github RyanCCollins / ryancollinsio-v2 / models / User.js View on Github external
var keystone = require('keystone');
var transform = require('model-transform');
var Types = keystone.Field.Types;

var User = new keystone.List('User');

User.add({
  name: { type: Types.Name, required: true, index: true },
  email: { type: Types.Email, initial: true, required: true, index: true },
  avatar: { type: Types.CloudinaryImage },
  bio: { type: Types.Markdown, height: 150 },
  website: { type: Types.Url, note: 'Full url, including http://' },
  twitter: {
    username: { type: String, note: 'Twitter username' },
    url: { type: Types.Url, note: 'Full url, including http://' }
  },
  github: {
    username: { type: String, note: 'Twitter username' },
    url: { type: Types.Url, note: 'Full url, including http://' }
  },
  password: { type: Types.Password, initial: true, required: true }
github zapkub / cu-vivid-museum-wiki / legacy / server / models / Report.js View on Github external
const keystone = require('keystone')
const path = require('path')
const ReportLevelEnum = require('./enum/ReportLevelEnum')

const Types = keystone.Field.Types

const ReportImageStorage = new keystone.Storage({
  adapter: keystone.Storage.Adapters.FS,
  fs: {
    path: path.join(__dirname, '../../static/images/report'),
    publicPath: '/static/images/report'
  }
})

const Report = new keystone.List('Report', {
  defaultSort: 'createdAt',
  map: { name: 'topic' }
})

Report.add({
  topic: { type: String, label: 'หัวข้อ' },
  targetURL: { type: String },
  description: { type: String },
  level: { type: Types.Select, options: ReportLevelEnum.enum },
  screenshot: { type: Types.File, storage: ReportImageStorage }
})

Report.defaultColumns = 'topic, description, level'
Report.register()
github JedWatson / sydjs-site / models / Link.js View on Github external
var keystone = require('keystone');
var Types = keystone.Field.Types;

/**
 * Links Model
 * ===========
 */

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

Link.add({
	label: { type: String, required: true, initial: true },
	href: { type: Types.Url, required: true, initial: true },
	description: { type: Types.Markdown, initial: true },
	state: { type: Types.Select, options: 'draft, published, archived', default: 'draft', index: true },
	tags: { type: Types.Relationship, ref: 'LinkTag', many: true },
	author: { type: Types.Relationship, ref: 'User', index: true },
	publishedDate: { type: Types.Date, index: true }
});
github promethe42 / dredd / api / models / Bill.js View on Github external
var keystone = require('keystone');
var transform = require('model-transform');
var elasticsearch = require('elasticsearch');

var Types = keystone.Field.Types;

var Bill = new keystone.List('Bill', {
});

Bill.add({
    legislature: { type: Types.Number, required: true, initial: true, index: true },
    number: { type: Types.Number, required: true, initial: true, index: true },
    registrationDate: { type: Types.Date, required: true, initial: true, index: true },
    importDate: { type: Types.Datetime, required: true, initial: true },
	text: { type: Types.Textarea, height: 400 }
});

Bill.schema.pre('save', function(next)
{
    var connectionString = 'http://127.0.0.1:9200';
    var client = new elasticsearch.Client({
        host: connectionString
    });