Module AssetDB
Methods
explore
(
-
url
)
- url
Reveal given url in native file system
name | type | description |
---|---|---|
url
|
string |
exploreLib
(
-
url
)
- url
Reveal given url's library file in native file system
name | type | description |
---|---|---|
url
|
string |
queryPathByUrl
(
-
url
-
cb
)
- url
- cb
queryUuidByUrl
(
-
url
-
cb
)
- url
- cb
queryPathByUuid
(
-
uuid
-
cb
)
- uuid
- cb
queryUrlByUuid
(
-
uuid
-
cb
)
- uuid
- cb
queryInfoByUuid
(
-
uuid
-
cb
)
- uuid
- cb
queryMetaInfoByUuid
(
-
uuid
-
cb
)
- uuid
- cb
deepQuery
(
-
cb
)
- cb
Query all assets from asset-db
examples:
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
(
-
pattern
-
type
-
cb
)
- pattern
- type
- cb
Query assets by url pattern and asset-type
name | type | description |
---|---|---|
pattern
|
string |
The url pattern |
type
|
string |
The asset type |
cb
|
function |
The callback function
|
examples:
Editor.assetdb.queryAssets( 'db://assets/**\/*', 'texture', function ( results ) {
results.forEach(function ( result ) {
// result.url
// result.path
// result.uuid
// result.type
});
});
import
(
-
rawfiles
-
destUrl
)
- rawfiles
- destUrl
Import files outside asset-db to specific url folder.
The import result will be sent through ipc message asset-db:assets-created
examples:
Editor.assetdb.import( [
'/file/to/import/01.png',
'/file/to/import/02.png',
'/file/to/import/03.png',
], 'db://assets/foobar' );
create
(
-
url
-
data
)
- url
- data
move
(
-
srcUrl
-
destUrl
)
- srcUrl
- destUrl
delete
(
-
urls
)
- urls
Delete assets by url list
The deleted results will be sent through by ipc message asset-db:assets-deleted
name | type | description |
---|---|---|
urls
|
array |
examples:
Editor.assetdb.delete([
'db://assets/foo/bar/foobar.js',
'db://assets/foo/bar/foobar02.js',
]);
save
(
-
url
-
data
)
- url
- data
saveMeta
(
-
uuid
-
metaJson
)
- uuid
- metaJson
urlToUuid
(
-
url
)
string
- url
fspathToUuid
(
-
fspath
)
string
- fspath
uuidToFspath
(
-
uuid
)
string
- uuid
uuidToUrl
(
-
uuid
)
string
- uuid
exists
(
-
url
)
string
- url
existsByUuid
(
-
uuid
)
string
- uuid
existsByPath
(
-
fspath
)
string
- fspath
isSubAsset
(
-
url
)
boolean
- url
isSubAssetByUuid
(
-
uuid
)
boolean
- uuid
isSubAssetByPath
(
-
fspath
)
boolean
- fspath
containsSubAssets
(
-
url
)
boolean
- url
containsSubAssetsByUuid
(
-
uuid
)
boolean
- uuid
containsSubAssetsByPath
(
-
path
)
boolean
- path
assetInfo
(
-
url
)
object
- url
assetInfoByUuid
(
-
uuid
)
object
- uuid
assetInfoByPath
(
-
fspath
)
object
- fspath
subAssetInfos
(
-
url
)
array
- url
subAssetInfosByUuid
(
-
uuid
)
array
- uuid
subAssetInfosByPath
(
-
fspath
)
array
- fspath
loadMeta
(
-
url
)
object
- url
loadMetaByUuid
(
-
uuid
)
object
- uuid
loadMetaByPath
(
-
fspath
)
object
- fspath
isMount
(
-
url
)
boolean
- url
isMountByPath
(
-
fspath
)
boolean
- fspath
isMountByUuid
(
-
uuid
)
boolean
- uuid
mountInfo
(
-
url
)
object
- url
mountInfoByUuid
(
-
uuid
)
object
- uuid
mountInfoByPath
(
-
fspath
)
object
- fspath
mount
(
-
path
-
mountPath
-
opts
-
[cb
]
)
- path
- mountPath
- opts
- [cb ]
mount a directory to assetdb, and give it a name. if you don't provide a name, it will mount to root.
name | type | description |
---|---|---|
path
|
string |
file system path |
mountPath
|
string |
the mount path (relative path) |
opts
|
object |
options |
cb
optional
|
function |
a callback function |
examples:
Editor.assetdb.mount('path/to/mount', 'assets', function (err) {
// mounted, do something ...
});