         return try convert(UInt(value))
     }
     func encode<T : Encodable>(_ value: T) throws -> Primitive? {
-        if let primitive = value as? Primitive {
+        if let primitive = value as? Primitive, !(primitive is _BSONFakePrimitive) {
             return primitive
         } else {
             var primitive: Primitive? = nil

    }
    
    func decode<T>(_ value: Primitive?) throws -> T? where T : Decodable {
        guard let value = value else {
            return nil
        }
        
        if T.self == ObjectId.self {
            let id = try BSON.unwrap(unwrap(value), codingPath: codingPath) as ObjectId as! T
            return id
        }
        
        let decoder = _BSONDecoder(target: .storedPrimitive(value))

    }
    
    func unwrap(_ value: Primitive?) throws -> Int? {
        guard let primitiveValue = value, !(primitiveValue is NSNull) else {
            return nil
        }
        
