Waterline.findOne()

Find a record that matches the specified criteria, and optionally populate its associations.

Usage

Hover over inputs/exits for more info.

var Waterline = require('machinepack-waterline');


// Find a record that matches the specified criteria, and optionally populate its associations.

Waterline.findOne({

model: 'user',

select: [ 'foo' ],

where: {},

populate: [ { association: 'friends', select: [ 'foo' ], where: {}, limit: -1, skip: 0, sort: [ 'name ASC' ] } ],

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// The provided `select`, `where` and/or `populate` was invalid.

invalidCriteria: function () {

 

},

// No record matching the specified criteria could be found.

notFound: function () {

 

},

// OK.

success: function (result) {

 

},

});

Inputs

model required

'user'
select

[ 'foo' ]
where

{}
populate

An array of assocations to populate.

[ { association: 'friends',
    select: [ 'foo' ],
    where: {},
    limit: -1,
    skip: 0,
    sort: [ 'name ASC' ] } ]

Exits

error

An unexpected error occurred.

invalidCriteria

The provided `select`, `where` and/or `populate` was invalid.

notFound

No record matching the specified criteria could be found.

success

OK.

{}