node.js – How to apply server side datatable regex ( search ) ( filter ) using node js on different columns of two or more combined (populated )collections

i am getting data form two collections of mongodb using nodejs..one is student collection and other is books…in this project i am assuming that this is one to many relation (one student can read multiple books but each book will be read by only one student)..this could be a many to many relation but i m working with the situation (one student can read multiple books at a time but each book will be read by only one student at a time)..Now by using populate function in ( node js ) i am getting all the columns data of a books collection and student collection using Book model because i used the reference of student model in books but when i apply datatable server side regex search on all columns it only filters the column of books collection and not working for the columns belongs to Student collection.

const mongoose = require('mongoose');
const BookSchema = mongoose.Schema({
student:{
    type:mongoose.Schema.Types.ObjectId,
    ref: 'Student'
},
    title: String,
    code: String,
    edition:String
});
module.exports = mongoose.model('Book', BookSchema,'books'); 
const mongoose = require('mongoose');  // following is a student model (schema)
const StudentSchema = mongoose.Schema({
    name: String,
    rollnumber: String,
    class: String,
});
module.exports = mongoose.model('Student', StudentSchema,'students');



    app.post("/testrelations", function(req, res) {
        var query = req.body.search.value;
if(req.body.search.value) {
            regex = new RegExp(req.body.search.value, "i")
            query = { $or: ({'title': regex},
                    {'code': regex },
                    {'edition': regex},
                    {'studnt.rollnumber': regex}, // this is not filtering
                ) };
        }
        else{
            query = {};
        }



                Book.count(query).populate("student").exec(function(err, user) {
                recordsTotal = user;
                Book.count(query, function (err, c) {
                    recordsFiltered = c;
                    console.log(req.body.start);
                    console.log(req.body.length);
                    Book.find(query).populate("student").exec(function(err, results) {
                        if (!results) {
                            console.log('error while getting results' + err);
                            return;
                        }
                        var get_columns= ();
                        var obj = {};
                        for (var i = 0; i < results.length; i++) {
                            var obj = {
                                _id: results(i)._id,
                                code: results(i).code,
                                title: results(i).title,
                                student_name:results(i).student.name,
                                roll_num:results(i).student.rollnumber
                            }
                            get_columns.push(obj);
                        }



      var data = JSON.stringify({
                            "draw": req.body.draw,
                            "recordsFiltered": recordsFiltered,
                            "recordsTotal": recordsTotal,
                            "data": get_columns
                        });
                        res.send(data);
                    });
                })
            })
            })

Per-location view settings or columns layout Per Folder

Please help with the following issue.

I just want to select different view setting per folder.
I have tried everything and it does not work.
I tried Per-location view settings or modify view to be applied to specific folder and it does not work.
Εvery time I browse the folders, all the folders have the same view.
Εvery time I show or hide columns in specific folder, all the folders have the same columns.
This is not normal and I can not understand the way sharepoint works.

PLEASE HELP

html: I have three columns but everything should be in two columns

This html code "Date Accessed" is in one column (at the top as a header), while the actual dates are in another column, but they’re all supposed to be in one column. I can’t figure out why.

<!DOCTYPE html>
{% load static %}
<html>
  <head>
    <meta charset="utf-8">
    <title>Django Level Two</title>
    <link rel="stylesheet" href="{% static "css/mystyle.css" %}"/>
  </head>
  <body>
  <h1> Hi welcome to Django Level Two <h1>
  <h2> Here are your access records:<h2>

  <div class="djangtwo">
    {% if access_records %}
    <table>
      <thead>
        <th>Site Name</th>
        <th>Date Accessed</th>
      </thead>

      {% for acc in access_records %}
    </tr>
        <td>{{acc.name}}<td>
        <td>{{acc.date}}<td>
      <tr>
      {% endfor %}
      </table>
      {% else %}
      <p>NO ACCESS RECORDS </p>
      {% endif %}

  </div>
  </body>
</html> 

the problem is not in the .css file but here it is anyways

h1{
  color: red;
}
table, th, td {
  border: 2px solid black
}

any help would be greatly appreciated-thnx

Entering a “Tab” character into Google Docs, when your document has columns

I am working with a two-column document in Google Docs. The 1st column is a field description. In the 2nd, wider column, I have free text to complete the field information. In this column, I have setup a left tab stop, so some information lines up near the far right of the column. However, I cannot enter a “tab” character to get the text to move to this new tab stop. If I hit the “Tab” key, I jump to the next column entry.

How can I insert a “tab” whitespace character? Ctrl-Tab/Shift-Tab/Ctrl-i – nothing I’ve tried to-date works.

PostgreSQL – Check value is not the same in multiple columns

I have a table to hold user information and is used as part of the login/registration process.
Part of the requirement is to allow the user to login using either their username or email address.
A snippet of the table is below and DB is PostgreSQL 12.4

CREATE TABLE account_users
(
    id            int          default nextval('postgres.account_users_id_seq'),
    username      varchar(100) not null unique,
    email         varchar(100) not null unique,
);

However this has raised a concern that the username field could be set to an email address of another user, which could cause a potential issue with users being able to login to their account as the SQL to get the users password from the database is:

SELECT password FROM account_users WHERE username = $1 or email = $1 LIMIT 1;

What I’m looking for is a way to ensure that the value in username and email are not the same for any row

For example:

username          | email
----------------------------------------------
user1             | user1@example.com - OK
user2             | user2@example.com - OK
user3@example.com | user3@example.com - Not OK
user1@example.com | user4@example.com - Not OK

Is this possible to do at the DB level or would it be something for the application to handle?

There is going to be validation done at the application level, client-side and server-side, however would a be nice to have if the DB could also catch this as well.

css – wp_list_pages two columns

I have a piece of code that splits my wp_list_pages navigation into two columns:

<div id="head">
    <ul>
        <?php
            $page_s = explode("</li>",wp_list_pages('title_li=&echo=0&depth=1'));
            $page_n = count($page_s) - 1;
            $page_col = round($page_n / 2);
            for ($i=0; $i < $page_n; $i++){
                if ($i < $page_col){
                    $left = $left.''.$page_s($i).'</li>';
                } else if ($i>=$page_col) {
                    $right = $right.''.$page_s($i).'</li>';
                }
            }
        ?>
        <div id="nav">
            <div>
                <?php echo $left; ?>
            </div>
            <div>
                <a href="http://wordpress.stackexchange.com/<?php bloginfo("url'); ?>"><img src="https://wordpress.stackexchange.com/<?php bloginfo("template_directory'); ?>/images/logo.png" alt="Logo" title="Logo" /></a>
            </div>
            <div>
                <?php echo $right; ?>
            </div>
        </div>
    </ul>
</div>

This code is working great! The problem becomes the depth parameter, when I remove it so the children of the menu show, then it comes out looking awful because the code is trying to split everything in wp_list_pages not just the parent menu items.

What I am trying to do is have the children menu items show when someone hovers over the link (dropdown), then when the page gets smaller, I’d like them to become part of the list of menu items – so people can still see them, they just won’t hover because that’s not possible on smaller screens.

My CSS looks like:

#nav {
      display: flex;
      text-align: center;
      width: 100%;
}

#nav div {
      align-items: center;
      display: flex;
      flex: 1;
      justify-content: center;
}

#nav div li {
      flex: 1;
      font-family: 'Lato', sans-serif;
      font-size: 15px;
      font-weight: 300;
      letter-spacing: 5px;
      text-transform: uppercase;
}

#nav div li.current_page_item a {
      font-weight: 400;
}

#nav div li.current_page_item a,
#nav div li a:hover {
      border-bottom: 1px solid #4a5f73;
}

#nav div a {
      border-bottom: 1px solid transparent;
      color: #4a5f73;
      padding: 0 5px 5px 10px;
      text-decoration: none;
}

#nav div img {
      height: auto;
      margin: 0 auto;
      max-width: 450px;
      width: 100%;
}

@media screen and (max-width: 1200px) {
    #nav {
           flex-direction: column;
    }
    #nav div li {
           padding: 20px 0;
    }
}

@media screen and (min-width: 1199px) {
    #nav div li {
           padding: 65px 0 30px;
    }
}

Fiddle: https://jsfiddle.net/uodhenyL/

Any help is appreciated.

Thanks,
Josh

database design – What type of normalization is it if I “flip” columns to rows

Suppose I have this:

 ID    A_Type    B_Type    C_Type
 ----  --------  --------  --------
 1     Y         N         N
 2     N         Y         Y

And I “flip” those columns into this:

 ID    Type    Value
 ----  ------  -------
 1     A       Y
 1     B       N
 1     C       N
 2     A       N
 2     B       Y
 2     C       Y

I know this is fine to do. I know it means I don’t have to change the target table in the second design if I have a new type, where I would have to in the first design. That is, I get the pros and cons and such.

But I’m interested in the theory. What is the normal form of the first table, and what is the normal form of the second table?

Most things about normalization give you a normal form, then show an example. I’m trying to go the other direction. We do this pattern all the time, so given this example, what is the normal form? Both before and after.

Thanks!

sharepoint online – ReadOnlyField Vs ReadOnlyEnforced when creating Site Columns

When creating a new site column inside Sharepoint Online, we have 2 options to set: ReadOnlyField and ReadOnlyEnforced.

So, what are the differences between these 2 settings?

As far as, I know ReadOnlyField means below points:

  • It can not be edited using the new, edit and quick edit forms.

  • It can be updated inside our code using CSOM (for example if we have a remote event receiver we can update the ReadOnlyField inside the code).

oracle – ORA-01789: query block has incorrect number of result columns

I am trying to solve this problem but somehow I couldn’t.
I get error

ORA-01789: query block has incorrect number of result columns

As I see the problem is UNION.

  SELECT * FROM(
          SELECT
               ia.ATAID, 
               ia.ataComment,
               ia.Type,
               ia.AtaNumber, 
               ia.DeviationNumber, 
               ia.ProjectID, 
               ia.Name, 
               ia.StartDate, 
               ia.DueDate, 
               ia.RevisionDate, 
               ia.Status, 
               ia.Ata, 
               ia.Deviation, 
               ia.Locked, 
               ia.PaymentType, 
               ia.BecomeExternalAtaFromInternal, 
               ia.Author, 
               ia.AtaType, 
               ia.DeviationType, 
               ia.PDFUrl, 
               ia.street, 
               ia.city, 
               ia.zip, 
               ia.briefDescription, 
               ia.ConfirmStatus, 
               ia.Token, 
               ia.ParentAta, 
               ia.EmailSent, 
               ia.ClientComment,
               ia.AnswerEmail, 
               ia.AnswerTime, 
               ia.UserID, 
               ia.FromFortnox,
               ia.ForFortnox, 
               ia.client_answer_attachment, 
               debitform.Name as paymentTypeName,
               CONCAT(CONCAT(users.Surname, ' '),users.Lastname) AS AuthorName,
               ia.Description, 
               ia.Reason, 
               ia.Suggestion, 
               ia.State, 
               'ata_become_external' as AtaTable,
               ia.WeeklyReports, 
               ia.Documents AS Attachment, 
               ia.articlesAdditionalWork AS articlesAdditionalWorkFromia, 
               ia.enabledAccounts, 
               ia.DefaultWeeklyReports, 
               ia.articlesMaterial AS articlesMaterialFromia, 
               ia.articlesOther AS articlesOtherFromia, 
               ia.WeeklyReportsMomentsPerWeek,
                NULL AS becomeFastFromOtherType
            FROM 
               internal_atas  ia
            LEFT JOIN
                users
            ON
                ia.Author = users.UserID
            LEFT JOIN
                 debitform
             ON
                 debitform.Id = ia.PaymentType
             WHERE 
                  ia.ATAID = 1189 
                        OR 
                            ia.ParentAta = 0

                    UNION 
                    
                       SELECT a.ATAID, 
                              a.ataComment, 
                              a.Type, 
                              a.AtaNumber, 
                              a.DeviationNumber, 
                              a.ProjectID, 
                              a.Name, 
                              a.StartDate, 
                              a.DueDate, 
                              a.RevisionDate, 
                              a.Status, 
                              a.Ata, 
                              a.Deviation, 
                              a.Locked, 
                              a.PaymentType, 
                              a.BecomeExternalAtaFromInternal, 
                              a.Author, 
                              a.AtaType, 
                              a.DeviationType, 
                              a.PDFUrl, 
                              a.street, 
                              a.city, 
                              a.zip, 
                              a.briefDescription, 
                              a.ConfirmStatus, 
                              a.Token, 
                              a.ParentAta,
                              a.EmailSent, 
                              a.ClientComment,
                              a.AnswerEmail, 
                              a.AnswerTime, 
                              a.UserID, 
                              a.FromFortnox, 
                              a.ForFortnox, 
                              a.client_answer_attachment,
                              debitform.Name as paymentTypeName, 
                              CONCAT(CONCAT(users.Surname, ' '),users.Lastname) AS AuthorName,
                              NULL AS Description, 
                              NULL AS Reason, 
                              NULL AS Suggestion,
                              NULL AS State, 
                              'ata' as AtaTable , 
                              NULL AS WeeklyReports, 
                              NULL AS Attachment,
                              NULL AS articlesAdditionalWorkFromia, 
                              NULL AS enabledAccounts, 
                              NULL AS DefaultWeeklyReports, 
                              NULL AS articlesMaterialFromia, 
                              NULL AS articlesOtherFromia, 
                              NULL AS WeeklyReportsMomentsPerWeek, 
                              a.becomeFastFromOtherType
                        FROM 
                            ata  a
                        LEFT JOIN
                            users
                        ON
                            a.Author = users.UserID
                        LEFT JOIN
                            debitform
                        ON
                            debitform.Id = a.PaymentType
                        WHERE 
                            a.ATAID = 1889
                        OR 
                            a.ParentAta = 0
                        )  a
                    ORDER BY a.ATAID

Somehow I try to change UNION to UNION ALL but still have same problem. Anyone how can guide me and tell me what is wrong here ? Where I made mistake ?