Monday, 26 January 2015

A new type of keystonejs ObjectArray (sub object collection)

As people are discussing about keystone issue 153 (, Keystonejs users expect to have a sub-collection or sub object list/array.

Mongodb is a new database, which does not like traditional database. We can put sub-object and sub-collection(sub-array) into a table(to avoid confuse you I will keep calling mongodb collections as table). However Keystonejs does not support that, Keystonejs still suggest to use reference to connect to another table.

But a lot of users want have the functionality. So this post is aiming to explain How to implement sub objectArray in keystonejs.

Is that what you want? :

I hope this is what you want!!

How to implement it:

You almost got it, just one last step:

Put one more dependency into your package.json file:


The real last step:


npm install

then you can start your application by:

node keystone.js

Example code:

Source code of this solution:

As you can see, my solution is all in a nodejs package -- keystoneplus. You can find the source code here:

Further read:

For more technical depth of how this sub-collection was implemented, please click below link hardly:


Massive thanks to M&S for sponsoring this project.

Of cause many thanks to all contributors of Keystonejs!!!!

No comments:

Post a comment