I am uploading the images from an IOS application to Firebase which returns to me the metadata including the URL of type URL
.
Should I store it of type String
in the database like below code? or there is specific type for URL
s?
var schema = new Schema({
downloadURL: { type: String, createdDate: Date.now }
})
Well, As per the docs Monngoose doesn't have a schema type for URL. You could just use a string with RegExp to validate it or use some custome made type like this one
var mongoose = require('mongoose');
require('mongoose-type-url');
var UserSchema = new mongoose.Schema({
url: {
work: mongoose.SchemaTypes.Url,
profile: mongoose.SchemaTypes.Url
}
});