' Gambas module file

Public Sub Main()

  Dim hClient As MongoClient
  Dim cResult As Collection
  Dim hResult As MongoResult
  Dim cDoc As Collection
  Dim hTable As MongoCollection
  Dim N As Integer
  Dim vVal As Variant
  Dim sId As String
  Dim cIndex As Collection
  Dim sIndex As String
  Dim cVoid As Collection
  
  Component.Load("gb.util.web")

  hClient = New MongoClient("mongodb://10.254.16.28")

  'Print hClient.Databases.Join()
  
  hClient.Database = "preprod_cig_mysarp_net"
  
  Print hClient.Collections.Join()
  
  Print hClient["activite"].Count
  
  cVoid = New Collection
  
  For Each cDoc In hClient["activite"].Query(cVoid, ["sort": ["nom": -1]])
    Print JSON.ToString(cDoc)
  Next
  
  Print hClient["activite"].Find(, ["sort": ["nom": -1]]).Join()
  
  
End
