Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

150
Vistas
How can I add a user with KeystoneJS if I don't have any users?

Sorry if this is an incredibly basic question but I can not find any helpful information out there.

I used the yeoman keystone generator to create a keystone project but MongoDB wasn't working when I ran the generator so the user didn't get created. I can not find any information on how to add the user.

Here is what I tried:

I added this to the routes/views/index.js file so it would get executed when the page loads:

var user = new User({
    name: { first:'matt', last:'x' },
    email: 'me@m.com',
    password: 'password',
    isAdmin: true
});

user.save(function (err) {
    if (err) {
        // handle error
        return console.log(err);
    }

    // user has been saved
    console.log(user);
});

This added a user to the database, but I get this error when I try to login:

Sorry, an error occurred loading the page (500)

Must supply api_key

How do I resolve this?

Thanks for any help.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Use the built-in update functionality to add a new user. Add this code to an updates/0.0.2-admins.js file:

var keystone = require('keystone'),
    User = keystone.list('User');

exports = module.exports = function(done) {
    new User.model({
        name: { first: 'Admin', last: 'User' },
        password: 'admin',
        isAdmin: true
    }).save(done);
};

Can you post the full error regarding your API key, though?

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda