first question here..
first I want to explain my difficulty here please help me.
I'm studying mongodb, mongoose and express, my problem here is that I want to match the user database
with the pelatihan database
.
this is an example of the output that i already make ->
{
"nama": "asep hernawan",
"email": "asepsp71@gmail.com",
"nomor_pendaftaran": "1141112197116",
"tanggal-lahir": "11/12/1971",
"images": "Source URL to IMAGE",
"pelatihan":{
}
"tokens": [{
"_id": """token": "(should be user token that im already know how to generate with JWT)"
}]
}
so, here's the scheme ..
admin first enter the database for training, because training is indeed based on a schedule, and here the pelatihan database
should look like
{
"id": """nama_instansi": "akper_jakarta",
"tanggal_pelatihan": "27/02/2020",
"nama_pemimpin": "ibu. humairah",
"jenis_pelatiihan": "btcls",
}
after that during the training the user will register on the Android platform, and fill the data in user data. what I want is that the user enters the data including kota_pelatihan
,
tanggal_pelatihan
, and if the kota_pelatihan
and tanggal_pelatihan
are the same as in thetraining database
the output will be like this ->
{
"id": "",
"nama": "asep hernawan",
"email": "asepsp71@gmail.com",
"nomor_pendaftaran": "1141112197116",
"tanggal-lahir": "11/12/1971",
"images": "PDF FILE URL",
"pelatihan": {
"id": "",
"kota_pelatihan": "jakarta",
"nama_tempat": "akper jakarta",
"tanggal_pelatihan": "27/02/2020",
"jenis_pelatihan": "btcls"
},
"tokens": [{
"_id": "",
"token": "TOKENS FROM JWT"
}]
}
this is my current User schema in expreess ->
const userSchema = mongoose.Schema({
nama: {
type: String,
required: true,
trim: true
},
email: {
type: String,
required: true,
unique: true,
lowercase: true,
validate: value => {
if (!validator.isEmail(value)) {
throw new Error({error: 'Invalid Email address'})
}
}
},
nomor_pendaftaran: {
type: String,
require: true
},
Images: {
type: String,
require: false
},
tanggal_lahir: {
type: String,
required: true,
},
logbook: {
},
sertifikat :{
sertifikat_sos: Boolean,
sertifikat_kementrian: Boolean,
status: {
dikemas: Boolean,
dalam_perjalanan: Boolean,
diterima: Boolean
}
},
pelatihan: {
nama_instansi: String,
tanggal_pelatihan: String,
jenis_pelatihan: String
},
tokens: [{
token: {
type: String,
required: true
}
}]
});
I'm really just learning Mongoose, MongoBb and Express and this is a bit depressing. forgive me if my questions are complicated and forgive my english which is not fluent or good, cheers!