10 examples of 'findone sequelize' in JavaScript

Every line of 'findone sequelize' 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
5findOne () { return this }
127findOne(...args) {
128 return this.get().findOne(...args);
129}
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}
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}
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};
86findOneById (id) {
87 return this.findOneByQuery({'id': id})
88}
82findOne(collection, query) {
83 var that = this;
84 query = castQueryIds(query);
85 return new Promise(function(resolve, reject) {
86 var db = that._mongo.collection(collection);
87 db.findOne(query, function (error, doc) {
88 if (error) return reject(error);
89 return resolve(doc);
90 });
91 });
92}
1export async function up(sequelize) {
2 // language=PostgreSQL
3 await sequelize.query(`
4 CREATE TABLE "keywords" (
5 "id" SERIAL UNIQUE PRIMARY KEY NOT NULL,
6 "keyword" VARCHAR(30) UNIQUE NOT NULL,
7 "createdAt" TIMESTAMP NOT NULL,
8 "updatedAt" TIMESTAMP NOT NULL,
9 "deletedAt" TIMESTAMP
10 );
11 CREATE TABLE "keywords_entries" (
12 "keywordId" INTEGER NOT NULL
13 CONSTRAINT "keywords_entries_keywordId_fkey"
14 REFERENCES keywords
15 ON UPDATE CASCADE ON DELETE CASCADE,
16 "entryId" INTEGER NOT NULL
17 CONSTRAINT "keywords_entries_entryId_fkey"
18 REFERENCES entries
19 ON UPDATE CASCADE ON DELETE CASCADE,
20 "createdAt" TIMESTAMP NOT NULL,
21 UNIQUE("keywordId", "entryId")
22 );
23 `);
24
25 console.log('*Table keywords created!*');
26}
161value: function findOne(query) {
162
163 var url = this.baseUrl + '/' + this.model + '/findOne';
164 return this.get(url, query);
165}
81value: function findOne() {
82 var _collection6;
83
84 return this.$q.resolve((_collection6 = this._collection).findOne.apply(_collection6, arguments));
85}

Related snippets