Hi,
I would need an example of the code to update the data of a field of a document, could you help me?
I would need an example of the code to update the data of a field of a document, could you help me?
- get v0.61 of library (same Dropboxlink).example of the code to update the data of a field of a document
Dim m As Map = CreateMap("Nombre": "gabriela","Alias":"gabriela","Areas":"ingeneria")
users.add(m)
Dim ref As DocumentReference = value ' you need to have this already
ref.setEventname("UserWatch","Update")
Log("DocumentReferenceId: "&ref.Id)
Dim m As Map = CreateMap("Nombre": "gabrielanew")
ref.merge(m,"update") ' add Nombre field to document replacing the existing Field.
Dim ref As DocumentReference = value
ref.setEventname("UserWatch","Update")
Log("DocumentReferenceId: "&ref.Id)
Dim m As Map = CreateMap("Nombre": "gabrielanew","Alias":"gabriela","Areas":"ingeneria")
ref.update(m,"update")
Public Sub ubicacionmodificada(Location1 As Location) ' gps actualizacion de ubicacion
fs.Initialize("Firestore",True)
loc.Initialize(Location1.Latitude,Location1.Longitude)
Dim usuarios As CollectionReference= fs.collection("usuarios","usuarios_coleccion")
If Starter.auth.CurrentUser.IsInitialized Then
If usuarios <> Null Then
' usuarios.setEventname("resultadovalidaciondatosusuario","Userlist")
usuarios.whereEqualTo("usuario_Uid",Starter.auth.CurrentUser.Uid).limit(25).fetch("usuarioscambiogps")
End If
End If
End Sub
Sub usuarioscambiogps_snapshot(success As Boolean, data As QuerySnapshot, info As String)
fs.Initialize("Firestore",True)
If data.Size > 0 Then
Log ("usuario cambio gps:" & success)
Dim documento As List = data.Documents
Dim cambio As DocumentReference
If documento.IsInitialized Then
'If documento > 0 Then
For i = 0 To documento.Size-1
Dim docsnap As DocumentSnapshot = documento.Get(i)
Dim cambio_gps As DocumentReference
Dim ref As DocumentReference = data.Documents ' you need to have this already
ref.setEventname("UserWatch","Update")
Log("DocumentReferenceId: "&ref.Id)
Dim m As Map = CreateMap("Nombre": "gabrielanew")
ref.merge(m,"update") ' add Nombre field to document replacing the existing Field.
Next
End If
End If
End Sub
Sorry, but learn to work with this lib. Make sure to consult the firebasedocumentation. I can not help you with every question you have.Sorry, but how do I do this?
Dim usr As DocumentReference = fs.document("Users/sYckIxPxDDsuV5m6k2Hr") ' This is the userid in MY Database for sure. Use the correct id from your database!
usr.setEventname("UserWatch","User")
Public Sub ubicacionmodificada(Location1 As Location) ' gps actualizacion de ubicacion
fs.Initialize("Firestore",True)
loc.Initialize(Location1.Latitude,Location1.Longitude)
Dim usuarios As CollectionReference= fs.collection("usuarios","usuarios_coleccion")
If Starter.auth.CurrentUser.IsInitialized Then
If usuarios <> Null Then
' usuarios.setEventname("resultadovalidaciondatosusuario","Userlist")
usuarios.whereEqualTo("usuario_Uid",Starter.auth.CurrentUser.Uid).limit(25).fetch("usuarioscambiogps")
End If
End If
End Sub
Sub usuarioscambiogps_snapshot(success As Boolean, data As QuerySnapshot, info As String)
fs.Initialize("Firestore",True)
If data.Size > 0 Then
Log ("usuario cambio gps:" & success)
Dim documento As List = data.Documents
If documento.IsInitialized Then
'If documento > 0 Then
For i = 0 To documento.Size-1
Dim docsnap As DocumentSnapshot = documento.Get(i)
Log("consulta Documento No: #"&i&": "&docsnap.Id)
Dim cambio_gps As DocumentReference =fs.document("usuarios/"& docsnap.Id)
cambio_gps.setEventname("actualizausuariosgps","Update")
Dim geo As Map
geo.Initialize
geo.Put("geo",loc)
cambio_gps.merge(geo,"update")
Next
End If
End If
End Sub