mongodb – How do I extend my script for an array of inputs?

I have a code that matches what I need. The codes start with a single hard-coded value for _id and the output gives me everything I need.

My problem is that I need to run this script repeatedly to retrieve the data for a set of _ids. I want to have a script that contains all _IDs. It's good that they are hard-coded.

1) I need to change this line to handle multiple IDs

var course_structure = db.modulestore.structures.find (
{"_id": ObjectId ("5123456ab8078204ef77ceaa")}). toArray ()[0]

I think it will look like $ add and remove [0]

var course_structure = db.modulestore.structures.find ({"_id": {$ in: [
] }}). toArray ()

2) The current output does not contain _id. I currently know the _id because I know which one is in the script. I run the script for an _id and use the output. Then repeat it. If a single execution of the script handles multiple _ids, _id must be included in the output so that I can determine which data belongs to which _id.

I do this from the command line, passing the output to a text file. I then import the text file into a relational database.

There are two sections of the issue. The block_types Sequential and Vertical section, the children subfield, is included in the output. For other block_types, the subfield is not included. This is because the child subfield exists only for these block_types.

(I skip most of my parameters)

mongo.exe MyDB C:  development  MyScript.txt> C:  development  MyOutput.json

This is the structure of my data

_I would
Edited on
-> BLOCKS (array of type object)
edit_info (object)
Edited on
Fields (object)
display name
-> CHILDREN (array type array)
-> (array of type string)
0: string
1: string

This is my current code that works correctly for a single _id

var course_structure = db.modulestore.structures.find ({"_id": ObjectId ("5123456ab8078204ef77ceaa")}). toArray ()[0]

var course_data = {
& # 39; # 39 & sequentially ;: [],
& # 39; # 39 & Vertical ;: [],
& # 39; # 39 & component ;: []

course structure['blocks'].forEach (function (block) {
var fields = block['fields']
    var block_type = block['block_type']
    if(['vertical', 'sequential'].indexOf (block_type)> -1) {
var block_data = {
& # 39; definition & # 39 ;: block['definition'],
& # 39; block_type & # 39;: block['block_type'],
& # 39; block_id & # 39 ;: block['block_id'],
& # 39; block_edited_on & # 39 ;: block['edit_info.edited_on'],
& # 39; display_name & # 39 ;: fields['display_name'],
"Children": fields['children']
course_data[block_type].push (block_data)
otherwise if (['html', 'done', 'problem', 'openassessment'].indexOf (block_type)> -1) {
var fields = block['fields']
        var block_data = {
& # 39; definition & # 39 ;: block['definition'],
& # 39; block_type & # 39;: block['block_type'],
& # 39; block_id & # 39 ;: block['block_id'],
& # 39; block_edited_on & # 39 ;: block['edit_info.edited_on'],
& # 39; display_name & # 39 ;: fields['display_name']
course_data['component'].push (block_data)
printjson (price data)

After some manipulations, z. For example, by changing some square brackets to curly braces, I import the data into SQL Server. This imports the block type "sequential".

section = & # 39; sequential & # 39;
, block_edited_on
,Display name
, Child_Block_Type
, Child_Block_ID
in # JSON_Data1
openjson (@JSON, & # 39; $. sequential & # 39;)
With (
- id varchar (4000) & # 39; $ ._ id & # 39;
-[edited_on] datetime & # 39; $ .edited_on & # 39;
        [definition] varchar (4000) & # 39; $ .definition & # 39;
, block_type varchar (4000) & # 39; $ .block_type & # 39;
, block_id varchar (4000) & # 39; $ .block_id & # 39;
, block_edited_on varchar (4000) & # 39; $ .block_edited_on & # 39;
, display_name varchar (4000) & # 39; $ .display_name & # 39;
, Children nvarchar (max) AS JSON
) as the core
Apply cross
openjson (children)
With (
Child_Block_Type varchar (4000) & # 39; $ .child_type & # 39;
, Child_Block_ID varchar (4000) & # 39; $ .child_block_id & # 39;
) as an array

Here is a small part of the current json output that does not contain _id

"sequential": [
        "definition" : ObjectId("51234561b807827583b64b3e"),
        "block_type" : "sequential",
        "block_id" : "3123456626004d6da21ed46cbcf22cea",
        "block_edited_on" : undefined,
        "display_name" : "Manually graded test",
        "children" : [

Computer Architecture – What Extend Opcodes? What are they good for? What would be a simple example?

Thank you for providing a response to the Computer Science Stack Exchange!

  • Please be sure answer the question, Provide details and share your research!

But avoid

  • Ask for help, clarification or answers to other answers.
  • Make statements based on opinions; secure them with references or personal experiences.

Use MathJax to format equations. Mathjax reference.

For more information, see our tips for writing great answers.

How to automatically extend the "Continue Reading" links on a profile page in Facebook?

Facebook tends to sort its contributions to "See More" or "Continue Reading". While one can extend the former, it is not possible to do with the latter. You are forced to click on the link and display the content on a new page. This form of posting is unproductive to me. I follow certain people on Facebook and regularly check their profile page to read their content. Because of links, I have to read the content separately, then return to the homepage and follow the reading for other posts. There are sometimes a handful of longer posts, so it's irritating for me to see them on a new tab / page.

I know that there is no solution from Facebook, as this is status-by-design, so I'm not looking for obvious answers, ie "No, it's not possible and so on …".

I came across a Javascript-based solution and it just adds Show More. For reading, all are automatically opened in new tabs. It only does half of what I need.

So how can I load the related links on the same page, as well as see more?

object-oriented – extend or create new interface?

I have an abstract class automobile and some children's classes as Carone, CarTwo,

Each car can contain different spare parts. There are also common spare parts for all cars. I have described this in the interface ICarParts {},

In any case, all classes realize this interface ICarParts,

So leave pictures Carone has common spare part and some own. Should I create my own interface for this class or just extend the base interface? ICarParts?

Finally, I have:

Class CarOne implements ICarParts, ICarOneParts {}

Class CarOne implements ICarOneParts {}

Where ICarOneParts ICarParts expands:

Interface ICarOneParts extends ICarParts {
newSpare: arbitrary;

With regard to the SOLID principles, it is necessary to create a different interface. What do you think?

uk – my visa expires soon, i have to extend it

I am a student in the UK. I failed in my second year in the first semester. For this reason, I repeated my 2nd year and it ends this month of January. But my 3rd year starts in October and my visa also ends in October. Now the university tells me that I have to return to my country and apply for another visa to complete the 3rd year of the CZ. I have a gap of 60 days or more in my studies. I do not want to go back because I'm not sure if I get a visa or not. Besides, I do not have enough money to come back and apply again should I do now. I would like to renew my visa in the UK. Is it something that will help me to apply for my visa from UK need visa extension. what should do

How do the free program identifiers (fpi) extend across constraints and type schemes in HM (X)?

Chapter 10 of the Advanced topics in Types and Programming Languages; gives a very comprehensive description of the type inference by resolving restrictions.

You introduce that free program identifiers an environment $ Gamma $ with the pair of equations $ fpi ( emptyset) = emptyset $ and $ fpi ( gamma; x: sigma) = fpi ( gamma) cup fpi ( sigma) $,

I would like clarification for that $ fpi ( sigma) $ Term. Does it contain the set of free type variables ($ ftv $)

Specifically, it says (page 408):

The set of free type variables of a type schema $ sigma $ and a restriction $ C $written $ ftv ( sigma) $ and $ ftv (C) $are defined accordingly … The quantities of the free program identifiers of a type scheme $ sigma $ and a restriction $ C $written $ fpi ( sigma) $ and $ fpi (C) $are defined accordingly. Note that $ x $ if free in $ x preceq T $,

The last sentence seems to indicate that type variables are program identifiers.

Are there any other program identifiers? Are predicates and the name of the soil types program identifiers?

Is the result of $ fpi (x rightarrow integer) $ the sentence $ {x, integer, rightarrow } $?

dnd 5e – Can Reincarnate extend the life of a target by reborn as a more durable breed?

When using Resurrection magic like revive or Summon deadIt is obvious that you return to life as you were before you died – in the same body, age, etc.

However, reincarnateThe druid's Resurrection spell forms a new body for the target. Since spells only do what they say, we must assume that you will be as old as you were before you died – but let's talk about it physically Age or mentally / current age?

For example, what happens if you are a 90-year-old human being reborn as a member of a longer-lived race like elves?
Are you now an Elf with a physical age of 90 (and therefore a handsome young elf)? Or are you the elven equivalent of a 90-year-old and therefore suffer from the disadvantages of old age (whatever they may be to elves)?