let objectIdString = (): string => %raw(new (require('mongoose').Types.ObjectId)
)
i want to bind to mongoose.Types.ObjectId function, without using %raw, how can i do it?
1 Like
I would probably do it like this:
module Mongoose = {
module ObjectId = {
type t
@module("mongoose") @scope("Types") @new
external make: unit => t = "ObjectId"
@send
external toString: t => string = "toString"
}
}
let id = Mongoose.ObjectId.make()
let str = id->Mongoose.ObjectId.toString
2 Likes