<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://logicwiki.co.uk/index.php?action=history&amp;feed=atom&amp;title=Sequelize_Model_Querying</id>
		<title>Sequelize Model Querying - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://logicwiki.co.uk/index.php?action=history&amp;feed=atom&amp;title=Sequelize_Model_Querying"/>
		<link rel="alternate" type="text/html" href="https://logicwiki.co.uk/index.php?title=Sequelize_Model_Querying&amp;action=history"/>
		<updated>2026-05-01T20:27:37Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>https://logicwiki.co.uk/index.php?title=Sequelize_Model_Querying&amp;diff=2250&amp;oldid=prev</id>
		<title>AliIybar: Created page with &quot;Category:Node.js Category:ORM Category:Database  == Model Querying - Finders == === findAll === It generates a standard SELECT query which will retrieve all entrie...&quot;</title>
		<link rel="alternate" type="text/html" href="https://logicwiki.co.uk/index.php?title=Sequelize_Model_Querying&amp;diff=2250&amp;oldid=prev"/>
				<updated>2021-11-25T12:38:17Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/Category:Node.js&quot; title=&quot;Category:Node.js&quot;&gt;Category:Node.js&lt;/a&gt; &lt;a href=&quot;/index.php?title=Category:ORM&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Category:ORM (page does not exist)&quot;&gt;Category:ORM&lt;/a&gt; &lt;a href=&quot;/index.php?title=Category:Database&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Category:Database (page does not exist)&quot;&gt;Category:Database&lt;/a&gt;  == Model Querying - Finders == === findAll === It generates a standard SELECT query which will retrieve all entrie...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Node.js]]&lt;br /&gt;
[[Category:ORM]]&lt;br /&gt;
[[Category:Database]]&lt;br /&gt;
&lt;br /&gt;
== Model Querying - Finders ==&lt;br /&gt;
=== findAll ===&lt;br /&gt;
It generates a standard SELECT query which will retrieve all entries from the table (unless restricted by something like a where clause)&lt;br /&gt;
=== findByPk ===&lt;br /&gt;
 const project = await Project.findByPk(123);&lt;br /&gt;
=== findOne ===&lt;br /&gt;
 const project = await Project.findOne({ where: { title: 'My Title' } });&lt;br /&gt;
=== findOrCreate ===&lt;br /&gt;
it will return an instance (either the found instance or the created instance) and a boolean indicating whether that instance was created or already existed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
const [user, created] = await User.findOrCreate({&lt;br /&gt;
  where: { username: 'sdepold' },&lt;br /&gt;
  defaults: {&lt;br /&gt;
    job: 'Technical Lead JavaScript'&lt;br /&gt;
  }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== findAndCountAll ===&lt;br /&gt;
The findAndCountAll method is a convenience method that combines findAll and count. This is useful when dealing with queries related to pagination where you want to retrieve data with a limit and offset but also need to know the total number of records that match the query.&lt;br /&gt;
&lt;br /&gt;
The findAndCountAll method returns an object with two properties:&lt;br /&gt;
&lt;br /&gt;
* count - an integer - the total number records matching the query&lt;br /&gt;
* rows - an array of objects - the obtained records&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
const { count, rows } = await Project.findAndCountAll({&lt;br /&gt;
  where: {&lt;br /&gt;
    title: {&lt;br /&gt;
      [Op.like]: 'foo%'&lt;br /&gt;
    }&lt;br /&gt;
  },&lt;br /&gt;
  offset: 10,&lt;br /&gt;
  limit: 2&lt;br /&gt;
});&lt;br /&gt;
console.log(count);&lt;br /&gt;
console.log(rows);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>AliIybar</name></author>	</entry>

	</feed>