|
|
@ -4,34 +4,16 @@ const bodyParser = require('body-parser') |
|
|
|
const MongoClient = require('mongodb').MongoClient; |
|
|
|
const mongo = require('mongodb') |
|
|
|
const fileUpload = require('express-fileupload'); |
|
|
|
const mongoose = require('mongoose'); |
|
|
|
//const mongoose = require('mongoose');
|
|
|
|
const fs = require('fs'); |
|
|
|
|
|
|
|
// Connection URL
|
|
|
|
const url = 'mongodb://192.168.0.2:27017'; |
|
|
|
|
|
|
|
// Database Name
|
|
|
|
const dbName = 'electro'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mongoose.connect('mongodb://192.168.0.2:27017/electro', {useNewUrlParser: true}) |
|
|
|
var imageSchema = new mongoose.Schema({ data: Buffer, contentType: String, fk_roller: {type: mongoose.Schema.Types.ObjectId, ref: "roller"} }) |
|
|
|
|
|
|
|
var Image = mongoose.model('images', imageSchema); |
|
|
|
|
|
|
|
var app = express(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var categories = {}; |
|
|
|
var questions = {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var image |
|
|
|
|
|
|
|
app.use(cors()) |
|
|
@ -172,9 +154,12 @@ const getCategories = (store, collectionName) => { |
|
|
|
|
|
|
|
const getQuestions = (store, collectionName) => { |
|
|
|
MongoClient.connect(url, function(err, client) { |
|
|
|
const db = client.db(dbName); |
|
|
|
const db = client.db(dbName)//.listCollections().toArray(res => {console.log(res)});
|
|
|
|
// Get the documents collection
|
|
|
|
const collection = db.collection(collectionName); |
|
|
|
collection.find().toArray((res) => { |
|
|
|
//console.log(res)
|
|
|
|
}) |
|
|
|
// Insert some documents
|
|
|
|
collection.find().sort({number:1}).project({_id: 0}).toArray((err,doc) => { |
|
|
|
console.log(doc) |
|
|
|