vlang / mongo

Official MongoDB driver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when using insert_one()

nac5604 opened this issue · comments

Error when using function collection.insert_one().

Code:

module sublib

import mongo

fn main() {
	mongo_uri := mongo.uri_new('xxx')
	client := mongo_uri.get_database('discord_bot')
	col := client.get_collection('discord_bot', 'user_data')

	col.insert_one({
		'str': 'string'
		'number': 2
		'float': 2.1
		'boolean': true
	})

	response := col.find({
		'str': 'string'
	}).lean()

	assert response[0].as_map()['str'] or { 0 }.str() == 'string'
}

Error:

C:/Users/xxx/.vmodules/mongo/src/collection.v:36:75: error: cannot use `&&C.bson_t` as `&C.bson_t` in argument 4 to `C.mongoc_collection_insert_one`
   34 |     reply := new_bson()
   35 | 
   36 |     result := C.mongoc_collection_insert_one(collection, document_bson_t, 0, &reply, &error)
      |                                                                              ~~~~~~
   37 |     unsafe { println(C.bson_as_json(&reply, 0).vstring()) }
   38 |     if unsafe { error.message.vstring() != '' } {

I've already updated V and Mongo-V. Hopefully this question is adequately formatted.

@enghitalo. Please, create tests