#3, добавила пользователей в фикстуры

parent 91cb450d
const mongoose = require('mongoose');
const config = require('./config');
const Category = require('./models/Category');
const Product = require('./models/Product');
const User = require('./models/User');
mongoose.connect(config.db.url + '/' + config.db.name);
const db = mongoose.connection;
db.once('open', async () => {
try {
await db.dropCollection('users');
await db.dropCollection('categories');
await db.dropCollection('products');
} catch (e) {
console.log('Collections were not present, skipping drop...');
}
const[user1, user2] = await User.create({
username: 'user',
password: 'user',
displayName: 'Some User',
phone: '+949205234052',
token: ''
}, {
username: 'user2',
password: 'user2',
displayName: 'Some User 2',
phone: '+324013248105',
token: ''
});
db.close();
});
...@@ -31,6 +31,6 @@ const ProductSchema = new Schema({ ...@@ -31,6 +31,6 @@ const ProductSchema = new Schema({
} }
}); });
const Product = mongoose.model("Product", ProductChema); const Product = mongoose.model("Product", ProductSchema);
module.exports = Product; module.exports = Product;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment