Friday 5 May 2017

capture location-string and store it in mongoDB

I'm trying to capture a text-generated string (client / session based) for when a user is uploading an image.

Output when doing db.collection.find(); from console right now when uploading:

"_id" : ObjectId("590c67f472667e031fe80a9d"), "path" : "uploads/bicycle.jpg", "originalname" : "bicycle.jpg", "__v" : 0

Here i want to have "imagelocation" : "N/A" also.

The string is based on a users location when uploading the image. I want to connect that specific strings value to the image-objects ID as displayed above.

path and originalname are declared as follows in my js:

var imageSchema = mongoose.Schema({
 path: {
 type: String,
 required: true,
 trim: true
 },
 originalname: {
 type: String,
 required: true
 },
 imagelocation:{ // format for storing
   type: String,
   required: true
 }

});

HTML:

<p id="coordinates">String is generated here</p>

TL;DR - how would i capture a string and send that along with the image when uploading it to my MongoDB?



via Joel

No comments:

Post a Comment