Skip to content

onenorth/keystone-singleton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

KeystoneJS | Singleton Plugin

A plugin that allows the creation of "singleton" KeystoneJS lists.

Disclaimer

While you are more than welcome to view the source, this is not an official KeystoneJS plugin and we discourage depending on this in production.

Installation

npm install --save git://github.com/onenorth/keystone-singleton.git#1.0.1

Description

This plugin prevents users from creating multiple items, and guarantees that an item is created automatically.

So if you want to make "Homepage Settings", we gotchu <3

Example Usage

HomepageSettings.js

const keystone = require('keystone')

// 1. Include the `singleton` option
const List = keystone.List('HomepageSettings', {
  singleton: true
})

// 2. Add in your fields.
List.add( /* ... */ )

// 3. Register your list.
List.register()

keystone.js

const keystone = require('keystone')
const singleton = require('keystone-singleton')

// 1. Initialize KeystoneJS
keystone.init( /* ... */ )

// 2. Initialize this plugin
singleton.init({ keystone })

// 3. Include your Models
keystone.import('models')

// 4. Start KeystoneJS
keystone.start()

Your KeystoneJS list will automatically be created on startup.

About

A plugin that allows the creation of "singleton" KeystoneJS lists.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published