10 examples of 'sequelize findone' in JavaScript

Every line of 'sequelize findone' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
127findOne(...args) {
128 return this.get().findOne(...args);
129}
88function findOne(db: Nedb, query: object): Promise> {
89 return new Promise((resolve, reject) => {
90 db.findOne(query, (error, doc) => {
91 if (error) {
92 return reject(
93 `An error happened whiling handling findOne: ${query} - ${error}`
94 );
95 }
96 if (doc) {
97 resolve(doc as T);
98 } else {
99 resolve(null);
100 }
101 });
102 });
103}
80findOne(id, cb) {
81 const self = this;
82 return pg(done => self.collection.findOne({
83 _id: id
84 }).lean().exec((err, res) => {
85 if (err) {
86 return done(err);
87 }
88 parse(res);
89 done(null, res);
90 }), cb);
91}
86findOneById (id) {
87 return this.findOneByQuery({'id': id})
88}
5findOne () { return this }
54findOne(id, cb) {
55 const self = this;
56 self.collection.findOne({
57 _id: id
58 }).lean().exec((err, res) => {
59 if (err) { return cb(err); }
60 cb(null, JSON.parse(JSON.stringify(res)));
61 });
62}
58public findOne(conditions: any) {
59 return (RoomCache.findOne(conditions, {
60 _id: 0,
61 locked: 1,
62 processId: 1,
63 roomId: 1,
64 })) as any as QueryHelpers;
65}
79const findOne = function findOne(id, next) {
80
81 this
82 .findOneById(id)
83 .exec((err, user) => {
84
85 if (err) {
86 return next(Boom.badImplementation());
87 }
88 if (!user) {
89 return next(Boom.notFound('User not found'));
90 }
91 return next(null, user);
92 });
93};
40db.projects.findOne({_id : db.ObjectId(id)}, function onFound(err, docs) {
41 if (err) {
42 throw err;
43 }
44
45 if (!docs) {
46 callback(null);
47 return;
48 }
49 callback(docs.assetFolder);
50});
229_findOne (query) {
230 return new Promise((resolve, reject) => {
231 this.db.findOne(query, (err, doc) => {
232 if (err) {
233 resolve({wasError: true, err})
234 } else {
235 resolve({wasError: false, doc})
236 }
237 })
238 })
239}

Related snippets