AssetDB
Editor.assetdb
remote
Editor.remote.assetdb
library
The library path
explore
Reveal given url in native file system Parameters
url**exploreLib
Reveal given url’s library file in native file system Parametersurl**queryPathByUrl
Get native file path by url Parametersurl**cb** The callback functioncb.path**queryUuidByUrl
Get uuid by url Parametersurl**cb** The callback functioncb.path**queryPathByUuid
Get native file path by uuid Parametersuuid**cb** The callback functioncb.path**queryUrlByUuid
Get asset url by uuid Parametersuuid**cb** The callback functioncb.url**queryInfoByUuid
Get asset info by uuid Parametersuuid**cb** The callback functioncb.info** Examples**
``````js Editor.assetdb.queryInfoByUuid( uuid, function ( err, info ) { // info.path // info.url // info.type });
queryMetaInfoByUuid
Get meta info by uuid Parametersuuid**cb** The callback functioncb.info** Examples**
``````js Editor.assetdb.queryMetaInfoByUuid( uuid, function ( err, info ) { // info.assetPath // info.metaPath // info.assetMtime // info.metaMtime // info.json });
deepQuery
Query all assets from asset-db Parameterscb** The callback functioncb.results** Examples**
``````js Editor.assetdb.deepQuery(function ( results ) { results.forEach(function ( result ) { // result.name // result.extname // result.uuid // result.type // result.children - the array of children result }); });
queryAssets
Query assets by url pattern and asset-type Parameterspattern** The url patterntype** The asset typecb** The callback functioncb.results**urlassetTypeExamples
``````js Editor.assetdb.queryAssets( 'db://assets/**\/*', 'texture', function ( results ) { results.forEach(function ( result ) { // result.url // result.path // result.uuid // result.type }); });
import
The import result will be sent through ipc messageasset-db:assets-createdParametersrawfiles** Rawfile path listdestUrl** The url of dest foldershowProgress** Show progress or notcb** The callbak function Examples**
``````js Editor.assetdb.import( [ '/file/to/import/01.png', '/file/to/import/02.png', '/file/to/import/03.png', ], 'db://assets/foobar' );
create
The created result will be sent through by ipc messageasset-db:assets-createdParametersurl**data**cb** Examples**
``````js Editor.assetdb.create( 'db://assets/foo/bar/foobar.js', 'var foobar = 0;');
move
The moved result will be sent through by ipc messageasset-db:assets-movedParameterssrcUrl**destUrl**showMessageBoxExamples
``````js Editor.assetdb.move( 'db://assets/foo/bar/foobar.js', 'db://assets/foo/bar/foobar02.js');
delete
The deleted results will be sent through by ipc messageasset-db:assets-deletedParametersurls** Examples**
``````js Editor.assetdb.delete([ 'db://assets/foo/bar/foobar.js', 'db://assets/foo/bar/foobar02.js', ]);
saveExists
The saved results will be sent through by ipc messageasset-db:asset-changedParametersurl**data**cb** the callback function Examples**
``````js Editor.assetdb.saveExists( 'db://assets/foo/bar/foobar.js', 'var foobar = 0;');
createOrSave
If the url is already existed, it will be changed with new data. The behavior is same with method saveExists. Otherwise, a new asset will be created. The behavior is same with method create Parametersurl**data**cb** the callback function Examples**
``````js Editor.assetdb.createOrSave( 'db://assets/foo/bar/foobar.js', 'var foobar = 0;');
saveMeta
The saved results will be sent through by ipc messageasset-db:asset-changedParametersuuid**metaJson**cb** the callback function Examples**
``````js Editor.assetdb.saveMeta( meta.uuid, JSON.stringify(meta, null, 2));
refresh
Refresh the assets in url, and return the results Parametersurl**cb** Examples**
``````js Editor.assetdb.refresh('db://assets/foo/bar/', function (err, results) { // assets that imported during init results.forEach(function ( result ) { if ( result.command === 'delete' ) { // result.uuid // result.url // result.path // result.type } else if ( result.command === 'change' || result.command === 'create' ) { // result.uuid // result.parentUuid // result.url // result.path // result.type } else if ( result.command === 'uuid-change' ) { // result.oldUuid // result.uuid // result.parentUuid // result.url // result.path // result.type } }); });
Editor
assetdb
The AssetDB instance
