mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
some timestamp helpers
This commit is contained in:
parent
9d792eb0c5
commit
c6a4f25e16
@ -122,6 +122,9 @@ namespace mongo {
|
|||||||
case BinData:
|
case BinData:
|
||||||
s << fieldName() << " : BinData";
|
s << fieldName() << " : BinData";
|
||||||
break;
|
break;
|
||||||
|
case Timestamp:
|
||||||
|
s << fieldName() << " : Timestamp " << timestampTime() << "|" << timestampInc();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
s << fieldName() << ": ?type=" << type();
|
s << fieldName() << ": ?type=" << type();
|
||||||
break;
|
break;
|
||||||
@ -442,6 +445,7 @@ namespace mongo {
|
|||||||
return f==0 ? 0 : 1;
|
return f==0 ? 0 : 1;
|
||||||
case Bool:
|
case Bool:
|
||||||
return *l.value() - *r.value();
|
return *l.value() - *r.value();
|
||||||
|
case Timestamp:
|
||||||
case Date:
|
case Date:
|
||||||
if ( l.date() < r.date() )
|
if ( l.date() < r.date() )
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -379,6 +379,14 @@ namespace mongo {
|
|||||||
type() == CodeWScope;
|
type() == CodeWScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned long long timestampTime() const{
|
||||||
|
unsigned long long t = ((unsigned int*)(value() + 4 ))[0];
|
||||||
|
return t * 1000;
|
||||||
|
}
|
||||||
|
unsigned int timestampInc() const{
|
||||||
|
return ((unsigned int*)(value() ))[0];
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// If maxLen is specified, don't scan more than maxLen bytes.
|
// If maxLen is specified, don't scan more than maxLen bytes.
|
||||||
BSONElement(const char *d, int maxLen = -1) : data(d) {
|
BSONElement(const char *d, int maxLen = -1) : data(d) {
|
||||||
|
@ -164,6 +164,16 @@ Local<v8::Object> mongoToV8( BSONObj & m , bool array ){
|
|||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
case mongo::Timestamp: {
|
||||||
|
Local<v8::Object> sub = v8::Object::New();
|
||||||
|
|
||||||
|
sub->Set( v8::String::New( "time" ) , v8::Date::New( f.timestampTime() ) );
|
||||||
|
sub->Set( v8::String::New( "i" ) , v8::Number::New( f.timestampInc() ) );
|
||||||
|
|
||||||
|
o->Set( v8::String::New( f.fieldName() ) , sub );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
cout << "can't handle type: ";
|
cout << "can't handle type: ";
|
||||||
cout << f.type() << " ";
|
cout << f.type() << " ";
|
||||||
|
Loading…
Reference in New Issue
Block a user