mongo-dart / bson Goto Github PK
View Code? Open in Web Editor NEWBson library for Dart programming language
License: MIT License
Bson library for Dart programming language
License: MIT License
If you have an empty list in your map, BsonCodec.serialize works, but BsonCodec.deserialize throws an error:
final simpleMap = {'emptyList': []};
final bson = BsonCodec.serialize(simpleMap);
final map = BsonCodec.deserialize(bson);
expect(map, simpleMap);
dart:typed_data Uint8List.[]
package:bson/src/types/bson_binary.dart 304:29 BsonBinary.readByte
package:bson/src/types/bson_array.dart 143:34 BsonArrayData._buffer2metaData
package:bson/src/types/bson_array.dart 121:52 BsonArrayData.metaArray
package:bson/src/types/bson_array.dart 19:29 new BsonArray._analyzeBsonArrayData
package:bson/src/types/bson_array.dart 14:17 new BsonArray.fromBuffer
package:bson/src/types/base/bson_object.dart 225:26 new BsonObject.fromTypeByteAndBuffer
package:bson/src/types/bson_map.dart 189:29 BsonMapData._buffer2metaData
package:bson/src/types/bson_map.dart 162:25 BsonMapData.metaDocument
package:bson/src/types/bson_map.dart 32:27 new BsonMap._analyzeBsonMapData
package:bson/src/types/bson_map.dart 28:15 new BsonMap.fromBuffer
package:bson/src/bson_codec.dart 26:20 BsonCodec.deserialize
test/main.dart 41:27 main.<fn>
RangeError (index): Index out of range: no indices are valid: 0
Is there a workaround for this (except for removing empty lists) or am I perhaps missing something?
Cached keys are unbounded. When there are documents with dynamic keys then the cache could grow until it uses up all the memory
http://docs.mongodb.org/manual/reference/object-id/
in short - start counter with random number, also there is different proportions but its not that important since the main reason of change is to get rid of 00000's in counter part of id
Just a curious about what's the usage of ObjectId(clientMode: true)
? A similar method as Mongoose
create it without inserting to real database? Can't find any comments or clue in the source code, so I ask here. Hope someone know the concept could share with ๐
There was recently an update to the Go driver that I thought could be applied to the Dart version as well, with help of the new Random functions. The Go driver issue can be found here.
I tried to find where bson uses random numbers for things such as the bson id's, and found that it seem they come from this file statics.dart.
What do you think @vadimtsushko, I'm not sure if all uses of Random should be updated to use cryptographically secure random, but at least at some places I think it would be beneficial. I don't think there is any big performance differences either, I think the new secure random should be efficient.
Hi guys thank's for this great library. Would it be possible to match the node library and add support for EJSON parse and stringify. For example :
import 'package:bson/ejson.dart';;
var text = '{ "int32": { "$numberInt": "10" } }';
// prints { int32: { [String: '10'] _bsontype: 'Int32', value: '10' } }
print(ejson.parse(text, { relaxed: false }));
// prints { int32: 10 }
print(ejson.parse(text));
Could you please make available this library on Pub?
To get myself started:
and a question:
what is the purpose of the json_ext.dart?
The error message is
NoSuchMethodError: The getter 'length' was called on null. Receiver: null Tried calling: length
Pub version for bson package : 0.3.1
Core stack code location:
bson-0.3.1/lib/src/types/binary.dart 86:20 BsonBinary.makeByteList
When taking a BsonMap from Map<String,dynamic>, bsonObjectFrom() is called, and it creates a BsonLong() or BsonInt() depending on the value. In some cases it'd be good to have a way to explicitly create a BsonLong (MongoDB, for example).
When trying to use the library using the following code
final serialized = BSON().serialize({'id': 42});
final deserialized = BSON().deserialize(serialized);
I get
Unhandled Exception: RangeError (index): Index out of range: index should be less than 13: 17
#0 Uint8List.[] (dart:typed_data-patch/typed_data_patch.dart:2221:7)
#1 BsonBinary.readByte (package:bson/src/types/binary.dart:256:29)
#2 BsonMap.extractData (package:bson/src/types/map.dart:13:27)
#3 BSON.deserialize (package:bson/src/bson_impl.dart:19:20)
#4 main (package:cool_tests/main.dart:35:31)
Am I using it in a wrong way?
The Endianness class (from dart:typed_data) was renamed in Dart 2 to Endian, and corresponding UPPERCASE_CONSTANTS were renamed to lowercast_constant versions. These Dart 2 changes should be updated in this package.
First let me say thank you so much for this library. Dart + mongodb + mongo_dart is a match made in heaven and exactly how I want to deal with my backend stuff. Thank you! This library helped free me from PHP finally!
That said, I think there should be some error checking with ObjectId.fromHex (or ObjectId.parse()). Currently I can pass in anything to construct a new ObjectId and I won't get any errors thrown until after I try to query the database. It would be great if ObjectId.parse could tell me as soon as I try to parse the string that it's not a valid hex string for an ObjectId.
BSON type 3 is not implemented yet according to the comments. I'd be happy to do the work, what needs to be done?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.