layout
default
menu_item
api
title
Odb
description
Version 0.26.1
return_to
API Documentation Index
/api/
sections
hashfile
open
#addDiskAlternate
#existsPrefix
#read
#readPrefix
#write
STREAM
#hashfile
#open
#addDiskAlternate
#existsPrefix
#read
#readPrefix
#write
#STREAM
Odb . hashfile ( path , type ) . then ( function ( oid ) {
// Use oid
} ) ;
Parameters
Type
path
String
file to read and determine object id for
type
Number
the type of the object that will be hashed
Returns
Oid
oid structure the result is written into.
Odb . open ( objects_dir ) . then ( function ( odb ) {
// Use odb
} ) ;
Parameters
Type
objects_dir
String
path of the backends' "objects" directory.
Odb# addDiskAlternate Async
odb . addDiskAlternate ( path ) . then ( function ( result ) {
// Use result
} ) ;
| Parameters | Type |
| --- | --- | --- |
| path | String | path to the objects folder for the alternate |
Returns
Number
0 on success; error code otherwise
odb . existsPrefix ( short_id , len ) . then ( function ( oid ) {
// Use oid
} ) ;
| Parameters | Type |
| --- | --- | --- |
| short_id | Oid | A prefix of the id of the object to read. |
| len | Number | The length of the prefix. |
Returns
Oid
The full OID of the found object if just one is found.
odb . read ( id ) . then ( function ( odbObject ) {
// Use odbObject
} ) ;
| Parameters | Type |
| --- | --- | --- |
| id | Oid | identity of the object to read. |
odb . readPrefix ( short_id , len ) . then ( function ( odbObject ) {
// Use odbObject
} ) ;
| Parameters | Type |
| --- | --- | --- |
| short_id | Oid | a prefix of the id of the object to read. |
| len | Number | the length of the prefix |
odb . write ( data , len , type ) . then ( function ( oid ) {
// Use oid
} ) ;
| Parameters | Type |
| --- | --- | --- |
| data | Buffer | buffer with the data to store |
| len | Number | size of the buffer |
| type | Number | type of the data to store |
| Flag | Value |
| --- | --- | --- |
| Odb.STREAM. RDONLY | 2 |
| Odb.STREAM. WRONLY | 4 |
| Odb.STREAM. RW | 6 |