S
S
Semyon Kataparov2017-09-19 22:23:14
JavaScript
Semyon Kataparov, 2017-09-19 22:23:14

What is the correct way to store a model in MongoDB?

The code:

import Game from '../models/game';
  const game = new Game({
    timeCreated: Date.now()
  });

  game.save((err, game) => {
    if(err) {
      console.log(err);
      return callback(err, null);
    }
    return callback(null, game);
  });

When saving, it does not display an error, but it does not execute the code either.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Abcdefgk, 2017-09-20
@truexizt1

new Game({
    timeCreated: Date.now()
}).save();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question