目前,我存放在Mongo,作为UUID(处理的必要)。 他们返回:
"_id" : new BinData(3, "JliB6gIMRuSphAD2KmhzgQ==")
把这一价值变成一种扼杀手脚的容易的方法是什么?
简言之,申请可以处理数据罚款。 我刚刚需要一个途径,迅速从刚果(金)获得真正的统一调查。
目前,我存放在Mongo,作为UUID(处理的必要)。 他们返回:
"_id" : new BinData(3, "JliB6gIMRuSphAD2KmhzgQ==")
把这一价值变成一种扼杀手脚的容易的方法是什么?
简言之,申请可以处理数据罚款。 我刚刚需要一个途径,迅速从刚果(金)获得真正的统一调查。
回答你的问题更加复杂,你会期望! 造成这种复杂性的主要原因是,由于历史原因(不尽人意),不同的司机利用不同的细心命令向数据库书写了UUID。 你没有提到你正在使用哪些司机,但我把C#司机作为例子。
Suppose I use the following code to insert a document:
var guid = new Guid("00112233-4455-6677-8899-aabbccddeeff");
collection.Insert(new BsonDocument {
{ "_id", guid },
{ "x", 1 }
});
如果我随后利用Mongo的炮弹审查该文件,那么它就认为:
> db.test.findOne()
{ "_id" : BinData(3,"MyIRAFVEd2aImaq7zN3u/w=="), "x" : 1 }
>
Mongo 壳体内有一条称为 he子的固定功能,你可以用来显示双亲价值,作为轴体:
> var doc = db.test.findOne()
> doc._id.hex()
33221100554477668899aabbccddeeff
>
仔细看看看: he子的细表与C#方案中使用的UUID原值相吻合。 这是因为C#的驾驶员使用Microsoft s ToByteArray的指南类别(可悲地将 by子带回去)的沥青指令,而事实是几个月来没有发现的。 其他司机有自己的属性。
为了帮助实现这一目标,我们在 Java文中写出一些可以装入Mongo壳的助手职能。 这些文件界定了:
https://github.com/mongodb/mongo-csharp-driver/blob/master/uuidhelpers.js
姆戈马舍尔可以接手档案,先提供指挥线档案的名称(与S-shell的论点一起)。 在填满这一档案后,我们可以利用一些助手职能,创造并展示作为统一倡议的宾达塔价值观。 例如:
C:mongodbmongodb-win32-x86_64-2.0.1in>mongo --shell uuidhelpers.js
MongoDB shell version: 2.0.1
connecting to: test
type "help" for help
> var doc = db.test.findOne()
> doc._id.toCSUUID()
CSUUID("00112233-4455-6677-8899-aabbccddeeff")
> db.test.find({_id : CSUUID("00112233-4455-6677-8899-aabbccddeeff")})
{ "_id" : BinData(3,"MyIRAFVEd2aImaq7zN3u/w=="), "x" : 1 }
>
举例来说,家庭调查中心的职能被用于显示作为家庭调查中心的本达塔价值,而家庭调查中心的职能则被用于利用C#司机的订货公约,为统一调查创建一种金塔价值,以便我们能够对统一调查。 其他司机也有类似职能(toJUUID、PYUD、JUID、PYUD)。
大约一天以后,所有司机都将按标准按班次顺序将新的二元次4标准化。 同时,你必须利用与你使用的任何司机相称的适当助手职能。
在您询问之前使用这一职能:
function ToGUID(hex) {
var a = hex.substr(6, 2) + hex.substr(4, 2) + hex.substr(2, 2) + hex.substr(0, 2);
var b = hex.substr(10, 2) + hex.substr(8, 2);
var c = hex.substr(14, 2) + hex.substr(12, 2);
var d = hex.substr(16, 16);
hex = a + b + c + d;
var uuid = hex.substr(0, 8) + - + hex.substr(8, 4) + - + hex.substr(12, 4) + - + hex.substr(16, 4) + - + hex.substr(20, 12);
return " + uuid + " ;
}
var id = new BinData(3, "JliB6gIMRuSphAD2KmhzgQ==");
ToGUID(id.hex());
Result:
"ea815826-0c02-e446-a984-00f62a687381"
如果你使用 Java的原始数据,你可以使用这一算法:
function ToUUID(hex) {
var msb = hex.substr(0, 16);
var lsb = hex.substr(16, 16);
msb = msb.substr(14, 2) + msb.substr(12, 2) + msb.substr(10, 2) + msb.substr(8, 2) + msb.substr(6, 2) + msb.substr(4, 2) + msb.substr(2, 2) + msb.substr(0, 2);
lsb = lsb.substr(14, 2) + lsb.substr(12, 2) + lsb.substr(10, 2) + lsb.substr(8, 2) + lsb.substr(6, 2) + lsb.substr(4, 2) + lsb.substr(2, 2) + lsb.substr(0, 2);
hex = msb + lsb;
var uuid = hex.substr(0, 8) + - + hex.substr(8, 4) + - + hex.substr(12, 4) + - + hex.substr(16, 4) + - + hex.substr(20, 12);
return uuid;
}
def binaryToUUID(byte: Array[Byte]): String = {
if (byte == null) null
else {
val bb = ByteBuffer.wrap(byte)
new UUID(bb.getLong, bb.getLong()).toString
}
}
如果您的蒙戈布司机使用javascript,那么你可以尝试这样做,以获得:
BinData(3,"ABEiM0RVZneImaq7zN3u/w==").toString( hex );
How can I deploy a Django project that uses MongoDB to AWS? I have a project made using Django and have been using MongoDB and its Compass app and was wondering if you could deploy said project and ...
Whats the best way to access/query a DB Ref: UPDATE: users: name, groupref : {$ref:"groups",$id:"ObjectId ..." } } groups: name, topic, country,...,.. Assumption is that user belongs to only one ...
Example: > db.stuff.save({"foo":"bar"}); > db.stuff.find({"foo":"bar"}).count(); 1 > db.stuff.find({"foo":"BAR"}).count(); 0
What re the best practices to store nested sets (like trees of comments) in MongoDB? I mean, every comment can have a parent comment and children-comments (answers). Storing them like this: { ...
I ve been using the following web development stack for a few years: java/spring/hibernate/mysql/jetty/wicket/jquery For certain requirements, I m considering switching to a NoSQL datastore with an ...
I m building a Rails application using MongoDB as the back-end and MongoMapper as the ORM tool. Suppose in version 1, I define the following model: class SomeModel include MongoMapper::Document ...
I have the following setup: Mac Pro with 2 GB of RAM (yes, not that much) MongoDB 1.1.3 64-bit 8 million entries in a single collection index for one field (integer) wanted Calling .ensureIndex(...) ...
My application creates pieces of data that, in xml, would look like this: <resource url="someurl"> <term> <name>somename</name> <frequency>somenumber</...