Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Metadata search addon for imboclient-js

License

Notifications You must be signed in to change notification settings

imbo/imboclient-js-metadata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm versionBuild StatusDependency status

Metadata search client addon

An addon for the Imbo javascript client. It provides the functions needed to query an Imbo installation set up with the metadata search extension.

Installation

Given that you've set up Imbo with the metadata search all you need to do is to install imboclient-metadata using npm:

npm install imboclient-metadata

Basic usage

There is no clearly defined add-on or plugin concept in the imboclient, but this add-on is written in a way that requires you to add the functions it exports to the Imbo.Client prototype for it to work. Exactly how you want to do this is up to you.

'use strict';

var Imbo = require('imboclient');
var metadata = require('imboclient-metadata');

// Add method to prototype
Imbo.Client.prototype.searchMetadata = metadata.searchMetadata;
Imbo.Client.prototype.searchGlobalMetadata = metadata.searchGlobalMetadata;

// Instantiate client
var client = new Imbo.Client('http://imbo', 'foobar', 'barfoo');

// Search for cat images using metadata across user and other-user
client.searchGlobalMetadata(
    // The metadata query to perform
    { animal: 'cat' },

    // Options
    {
        users: ['user', 'other-user'],

        // Whether to include metadata for images in response or not
        metadata: 1,

        // Which fields to return
        fields: ['width', 'height', 'imageIdentifer'],

        // Sort order of result set. Default is ordering from metadata backend
        sort: ['width:asc', 'height:desc']
    },

    function(err, body, meta, res) {
        console.log(err, body, meta);
    }
);

// Search for cat images using metadata across user and other-user
client.searchMetadata(
    // The user to search for images from
    'user',

    // The metadata query to perform
    { animal: 'cat' },

    // Options are the same as with searchGlobalMetadata, minus the users option
    {},

    function(err, body, meta, res) {
        console.log(err, body, meta);
    }
);

License

Copyright (c) 2015, Kristoffer Brabrand [email protected]

Licensed under the MIT License

About

Metadata search addon for imboclient-js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published