Snippets Collections

SELECT 
  organization_id,
  contact_id,
  email_id,
  session_id,
  visitor_id,
  event_name,
  event_source,
  tracking_source,
  event_date,
  event_type,
  event_id,
  `products.product_id`,
  `products.variant_id`,
  `products.quantity`,
  `products.price`,
  order_id,
  order_date,
  order_amount,
  order_status,
  order_coupons,
  billing_address,
  billing_city,
  billing_country,
  billing_country_code,
  billing_region,
  billing_phone,
  billing_postcode,
  billing_payment_method,
  session_ip_address,
  session_city,
  session_region,
  session_country,
  session_country_code,
  session_timezone,
  session_latitude,
  session_longitude,
  session_user_agent_device,
  session_user_agent_browser,
  session_user_agent_version,
  session_user_agent_platform,
  session_source,
  session_origin,
  session_social,
  session_medium,
  session_referrer,
  session_source_and_medium,
  session_campaign,
  Sign,
  insertion_date
FROM events.order
WHERE Sign = 1 AND organization_id = 2997030
INTO OUTFILE 'josh.csv' FORMAT CSV
dataframe['column_name'].value_counts().plot(kind='bar')
plt.show()
INSERTING ONE AND MANY
db.places.insertOne({})
db.places.insertMany({})

UPDATING - ONE AND MANY
db.places.updateOne({"country": "India"}, {$set: {"continent": "Europe"}})
db.places.updateMany({"country": "India"}, {$set: {"flag": "Updated Flag"}})

DELETING
db.places.deleteOne({"continent": "Africa"})
db.places.deleteMany({"continent": "Africa"})
db.places.findAndDelete({})

FINDING
db.students.find({"name":"Andy"})
db.students.find({"name":"Mike"})

FINDING using $OR and $IN
this will return entries that have hobbies of baseball OR MAC and Linux users
db.students.find( { $or: [ { "hobbies": { $in: ["Baseball"]}}. { "os" { $in: ["Mac", "Lin"]}}]})

also compatible with SOME regex expressions

SORTING:
db.animals.find().sort({weight: -1}); <== this is descending, a positive value is ascending



MYSQL
DB_NAME=
DB_PASSWORD=
DB_USER=root

MONGODB
Open Mongosh - copy string and add to:

-- config file notes

// Config is the only access of 'dotenv'

import dotenv from "dotenv";

dotenv.config();

export default {
  port: process.env.PORT || 3000,
  db: process.env.DB_CLIENT_URL,
};
npm install --legacy-peer-deps
npm cache clear --force
visitors = p.visitors.customers.where(tags: 'UNSUBSCRIBE 2021')
visitor_ids = visitors.pluck(:id);1

STATUSES_FOR_DELETION = [Automations::Trigger::Status::NOT_EXECUTED, Automations::Trigger::Status::RETRIGGERED].freeze
scheduled_steps = Automations::ScheduledStep.in(campaign_id: campaign_ids).in('triggers.visitor_id': visitor_ids)
scheduled_steps.map do |step|
  step.triggers.where(visitor: @visitor).in(status: STATUSES_FOR_DELETION).destroy_all
end

Mails::SingleEmail.where(project: p, sent_at: nil, processing: false).in(recipient_id: visitor_ids).destroy_all

Debug::MergeLog.where(project: p).in(legacy_visitor: visitor_ids).destroy_all

visitors.each.with_index do |visitor, index|
  visitor.events.destroy_all
  visitor.destroy

  puts index if index % 1000 == 0
end
{%- for block in section.blocks -%}
{%- assign product = all_products[block.settings.product] -%}
 <div class="img">{{ product.title }}</div>
{%- endfor -%}
<div id="section-{{ section.id }}">
  {%- for block in section.blocks -%}
    <ul>
      <li class="cate"> {{ block.settings.cate }} </li>
      <li class="date"> {{ block.settings.date }} </li>
      <li class="text"> {{ block.settings.text }} </li>
    </dl>
  {%- endfor -%}
</div>

{% schema %}
  {
    "name": "Top-topics",//セクション名
    "class": "top-topics",//セクションに自動で追加されるclass名
    "blocks": [// 画像や商品など数が増える可能性がある設定を記述する
      {
        "type": "text",
        "name": "Topic",//入力画面でのタイトル
        "limit": 5,
        "settings": [
          {
            "type": "select",
            "id": "cate",
            "label": "Category",
            "options": [
              {
                "value": "topics",
                "label": "Topics"
              },
              {
                "value": "news",
                "label": "News"
              }
            ],
            "default": "topics"
          },
          {
            "id": "date",
            "type": "text",
            "label": "日付を入力",
            "default": "2021.03.27"
          },
          {
            "id": "text",
            "type": "text",
            "label": "テキストを入力",
            "default": "テキストを入力"
          }
        ]
      }
    ],
    "presets":[
      {
        "category": "Text",//管理画面のセクション一覧のグループに表示される名前
        "name": "Top topics"
      }
    ]
  }
{% endschema %}

{% stylesheet %}

{% endstylesheet %}

{% javascript %}
{% endjavascript %}
star

Tue Apr 11 2023 14:26:54 GMT+0000 (Coordinated Universal Time)

#plaintext
star

Sun Oct 24 2021 07:15:37 GMT+0000 (Coordinated Universal Time)

#plaintext
star

Sat Aug 28 2021 16:52:53 GMT+0000 (Coordinated Universal Time)

#plaintext
star

Sat Aug 28 2021 14:16:51 GMT+0000 (Coordinated Universal Time)

#plaintext
star

Tue Aug 03 2021 18:25:07 GMT+0000 (Coordinated Universal Time)

#plaintext
star

Wed Jul 07 2021 09:19:01 GMT+0000 (Coordinated Universal Time)

#plaintext
star

Tue Apr 27 2021 07:16:12 GMT+0000 (Coordinated Universal Time)

#plaintext
star

Tue Apr 27 2021 04:52:33 GMT+0000 (Coordinated Universal Time)

#plaintext

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension